top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Form objects vs nested attributes in 1 to many association in rails

+1 vote
329 views

Recently I have been reading about form objects and have been wondering its use in 1 to many association. Let's say I have a model of project with many tasks and the user edits the project along with the tasks in one big form.

Is nested attributes using cocoon gem better suited than using reform/virtus or other form objects? Any examples of using form objects in this context?

posted Jul 14, 2013 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

Is there a more compact way to do a nested each ?

value.each do |x|
 x.data.each do |y|
 puts 'x: ' + x + ' y: ' + y
 end
end

That is can this be reduced to one or two lines?

+1 vote

I have a Rails application with a default time zone of UTC. This works fine for almost everything. Now I have a situation where I would like to present the values in a datetime_select offset by a specific time zone. As far as I know, this helper does not have an option to specify the time zone that is used when persisting this data. When the form is submitted, it only sends the year, month, day, hour, and minute fields. ActiveRecord is responsible for converting these values into the time zone configured for the application. In this case, I want to change the time zone for only these fields so that it is localized to the user (but still store the correct UTC time). How can I make this change?

+1 vote

I have just started with rails. I am making a attendance web app. I want to insert student attendance into attendances table and unable to do it as the form just inserts only last entry of the form. Student table and Attendances table have associations (has_many,belongs_to).

Please let me know how the form should be and controller API should look like.

+1 vote

I would like to have a form in which some of the fields are linked to model and some fields are not. When I use FORM_FOR tag it binds to a particular model and I cannot create form fields that aren't correspond to one of the column name of the table (Model). Hence what I think is I should use FORM_TAG instead of FORM_FOR so that it contains whatever the form fields it want but one thing I can't find by googling is how can I connect specific fields to a model leaving other fields free of model?

In other words, If I have 5 text_fields in a form how can I link only 3 text_fields to a model and leave other 2 fields free?

0 votes

Is it is possible to share a Rails 4 session with a Rails 4.1 application with the same secret key base on the same domain name. This works with Rails 4 to Rails 4 but it appears that my cookies are being encrypted differently between the two versions.

Any suggestions?

...