Line 1
Line 2
...
Line 999
Line 1000
# Ans: here is the view code: <Display 1000 Lines> <% (1..1000).each do |i| %> <p>Line <%= i %></p> <% end %>
<% form_for @cust, "display" |form| <p>Prefix: <% radio-button :prefix, 'Mr.', true %> <p>Prefix: <% radio-button :prefix, 'Ms.' %> <p>First Name: <% text-field :first_name, ' ' %> <% end %> <!-- Ans: Here is the corrected version: --> <%= form_for @cust, :url => { :action => 'display' } do |f| %> <p>Prefix: Mr. <%= f.radio_button :prefix, 'Mr.', :checked => true %> <%= f.radio_button :prefix, 'Ms.' %> <p>First Name: <%= f.text_field :first_name %> <p><%= f.submit 'Submit Name' %> <% end %>
@cust = new Customer[param(:cust)] # Ans: The corrected line is @cust = Customer.new(params[:customer])
<%= Customer.all.each |cust| %> <%= table %> <tr> <th>Name<th> <th>Customer Id</th> </tr> <tr> <td>c.name<td> <td>c.cust_id</th> </tr> <%= /table %> <% end %> <-- Ans: Here is the corrected output: --> <table> <tr> <th>Name<th> <th>Customer Id</th> </tr> <% Customer.all.each do |c| %> <tr> <td>c.name<td> <td>c.cust_id</td> </tr> <% end %> </table>
a = [2, 6, 4, 5, 1] # Example 1 b = a.collect do |x| 2 * x end print b, "\n" Ans: [4, 12, 8, 10, 1] # Example 2 b = (0..5).to_a.collect do |x| 2 * x + 1 end print b, "\n" Ans: [1, 3, 5, 7, 9, 11] # Example 3 b = (1..5).to_a.collect do |x| [x, x**2] end print b, "\n" Ans: [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25]]
has_many :flights
belongs_to :passenger