similar to: How can I use aggregation objects in form_for?

Displaying 20 results from an estimated 10000 matches similar to: "How can I use aggregation objects in form_for?"

2006 Aug 11
2
Accessing belongs_to objects from a form_for context
In a form_for context, is there a way to access objects that are related to the primary object with a belongs_to? I think an example will serve best: class User < ActiveRecord::Base belongs_to :person attr_accessor :username end class Person < ActiveRecord::Base has_one :user attr_accessor :first_name end <% form_for :user do |form| %> <%= form.text_field
2007 Oct 20
14
Problems with form_for and partials
i''m having problem with a form_for situation where i''m trying to DRY out the repeated parts of my forms and put them in common/form and render the form elements via another partial in controller_name/_form. Here''s the first form # app/views/common/form <% form_for ... do |f| -%> <%= render :partial => "params[:controller]/form", :object => f
2011 Jul 25
4
[Rails 3.0.9] I have trouble about fields_for
Hi,all. I''m new bee to Rails and I have trouble about fields_for method.. It isn''t show up between the <%= f.fields ~ <% end %> Please teach me some advice. Thanks! #new/_form.html.erb <%= form_for(@user) do |f| %> <div class="field"> <%= f.label :name %><br /> <%= f.text_field :name %> </div> <!-- Below
2013 Dec 10
2
form_tag + fields_for Rails 4
Hi There, I''m trying to user fields_for inside a form_tag, but i can''t catch it on my controller. I just take some html code off to makes it easy to read my view... i''m using campuses_path(current_church, @campus) instead form_for @campus, because my route is like resources :campuses, :path => ":church/campuses" <%= form_tag
2009 May 12
2
2.3 Nested Model Forms; build new without updating existing
I''m trying to build something similar to a Facebook messaging app, in which the view displays all the messages for a particular thread, with a form box for replying at the bottom of the thread. The problem is that using fields_for generates form fields for each existing record, and for one new record. In this case, there is no need to edit existing messages - just a need to add new
2008 Dec 02
4
Sharing a partial between multiple controllers
I want to share a partial between 2 or more controllers. I have a "location" partial that I want users to enter "Address, City, State, Zip" information in however I have "Payees", "Institution", and "Event" models that can have "location" information stored with them. Since I don''t want to duplicate the partial across each
2009 Oct 15
4
Getting the object in fields_for
I''m using the fields_for helper with accepts_nested_attributes_for The System model has_many children. If I do this in my haml template: -form_for @system do |s| =s.text_field :name -s.fields_for :children do |child_fields| =child_fields.text_field :name all is fine. The fields_for iterates over all children and puts the correct data in the fields. But...what I
2009 Feb 06
2
Using partials with form_for
hi all i was wondering whether it is possible to use partials along with form_for and form_field. following code is not working. is there some error or this case is impossible..?? *#new.html.erb* <h1>Enter Details for new Partner:</h1> <% form_for(@partner) do |f| %> <%= render :partial => ''form'', :locals => {:partner => f} %> <p>
2008 Apr 06
10
about the form_for ..
question one: is there any select box tag for form_for? now,perhaps i just can use the select or select_tag? question tow: i have a A model,it has one B such as: class A< ActiveRecord::Base belongs_to :B when i use the form_for tag,how can i output the variable name?like this: <%form_for :a,@a,:url=>{:controller=>"a",:action=>"save"} do |f|%>
2008 Jan 02
6
problem when editing record in polymorphic relation
I have the following three models created applying the polymorphic concept ========================================================================== class SoftwareCi < ActiveRecord::Base has_one :ci, :as => :content end class HardwareCi < ActiveRecord::Base has_one :ci, :as => :content end class Ci < ActiveRecord::Base belongs_to :content, :polymorphic => true end The
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
I have the following models: class Order < ActiveRecord::Base belongs_to :billing_address belongs_to :shipping_address accepts_nested_attributes_for :billing_address accepts_nested_attributes_for :shipping_address, :reject_if => proc { |attributes| attributes[''has_shipping_address''] != ''1'' } def after_initialize self.build_billing_address
2007 Oct 17
2
Complex Forms (From Railscasts.com)
Hi, I have been watching the last three episodes on railscasts.com in which he goes through dealing with multiple models in one for using fields_for, and virtual attributes. (http://railscasts.com/episodes/ 73). Here is an example of the way they suggest to go about it: # projects_controller.rb def new @project = Project.new 3.times { @project.tasks.build } end def create @project =
2009 Feb 09
2
how to get form parameters while using fields_for with nested attributes
hi all.. i am trying to use *fields_for* to get and save nested attributes in a form. i have a ''Partner'' model associated with an ''Address'' model. partner has_many :addresses although the form is displaying fine, but on submitting it the following error is shown: *can''t convert HashWithIndifferentAccess into Array* on this line: *@partner =
2009 Jul 01
2
Nested Forms - how to displayed the attributes content ?
I have a User model class User < ActiveRecord::Base has_one :account accepts_nested_attributes_for :account, :allow_destroy => true validates_associated :account attr_accessible :account_attributes is working fine, validating and updating both records (User and Account), but I caanot display the value in the form when is updated, ex: below the firstname is not displayed but
2006 Aug 02
7
form_for not working with Markaby
I''m playing around with Markaby and I decided to write a little blog app. I''m running into issues with forms however. If I use form_for the output of the form gets swallowed. For example: form_for :article, @article do |f| f.text_field :title f.check_box :published f.text_area :description f.text_field :pub_date f.text_area :content end gets rendered as an empty form
2007 Apr 25
2
form_remote_for, reloaded
Hi, being relativly new to RoR, I''m having a problem which I found described in this forum and somewhere else - but with no solution. I know, that it may be bad to mix table and form tags, but the first solution of an in place editing within a table looked nice: Version using form_for: <tr> <%form_for :time_record, :url => { :action => "add_time_record" } do
2006 Sep 24
8
form_for and Multiple Models Being Saved
Howdy Folks, I want to use form_for to allow a user to submit a form that contains two instances of the same model. They are entering calendar dates and I want them to be able to submit 2 from the same form. Ok, so, using form_for, what is the best way to do this? form_for seems to be setup to handle a single instance in that it wants a name for the variable, etc... Has someone else done this?
2006 Oct 13
2
form_for() and name
how can i give name attributes for form_for(), so it will give an output like <form name="f">. it is because that i need to access the form name for javascript manipulation. as far as i know, name can only used in form_tag(), but i currently have more than 50 forms that built using form_for(). the structure is like this: <% form_for symbol, item, :url => { :action
2006 Aug 05
1
form_for and partials
I''m getting an error in the partial when i try <% form_for :name do |form| %> <%= render_partial "#{@current_stage}" %> <% end %> So I assume that form_for does not have scope in the partial? If that is the case what are my solutions... Do I have to stick a <% form_for in every partial, or do i just change all my inputs back to text_field
2010 Aug 13
2
Rails 3 / ActiveModel for Credit Card information?
When submitting billing information in the past I''ve always used attr_accessor for credit card details as they should not be saved in the database. In addition I always end up storing the card expiration date so that the date form helper works correctly. With Active Model it seems logical to create a CreditCard class to hold this data instead. **1st issue.** It seems there still