similar to: Sharing a partial between multiple controllers

Displaying 20 results from an estimated 6000 matches similar to: "Sharing a partial between multiple controllers"

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
2011 Oct 26
6
Add an index to a form
Hello, I''m having some trouble with forms, my app allows to enter data by using a multi-step form that has 7 steps. There are 3 steps that may let the user to add 1 form, for example there''s a step called "children" and that children has the following fields: * name * age * gender but one father may have more than 1 child and I''m adding another form with
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
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
2010 Nov 28
6
has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
MODEL class User < ActiveRecord::Base has_one :address, :dependent => :destroy accepts_nested_attributes_for :address end CONTROL def new @user = User.new @user.build_address # Adicionei ... VIEW partial _form .... <% f.fields_for :address do |b| %> # Adicionei <%= b.text_field :city_manual %> # Adicionei <% end %>
2008 Dec 02
4
Am I wrong or is fields_for not working right in Rails 2.2.2
I may be totally wrong about what the fields_for method is supposed to do, but for some reason I thought using it scoped an object around an association. For example, I have a User class and when you''re creating a new user I want to use fields_for to add a BillingAddress to the user like so: <%- fields_for :billing_address do |billing_address_form| -%> <%= render :partial
2010 Nov 11
2
Rails 3 - Nested Forms, using Builder -- Check_box issue
Hello, I have the following: My Controller: def new . . @teammembers.each do |teammember| request = @request_thread.requests.build(:recipient_id => teammember.user_id, :full_name => ''Billy Bob T'') end My View: . . <%= f.fields_for :requests do |builder| %> <div class="field"> <%= builder.label
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 =
2007 May 19
3
form question
Suppose I have the following models/migrations: class Car < ActiveRecord::Base belongs_to :manufacturer validates_presence_of :manufacturer validates_association :manufacturer end class CreateCars < ActiveRecord::Migration def self.up create_table cars do |t| t.column :name, :string t.column :manufacturer_id, :integer end end class Manufacturer <
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 =
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
2007 Dec 31
2
episode 73 resulting in error: undefined method `stringify_keys!' for "33":String
I''m working with a similar model in Episode 73, (my scenario is editing multiple pictures for a product using attachment_fu). And I''m getting an error when I try the technique suggested: ./views/admin/_form.rhtml <% for picture in product.pictures %> <% fields_for "product[picture_attributes][]", picture do | picture_form| %> Title: <%=
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
2012 Sep 08
4
dash symbol
In the example below, what is the dash doing between the class attribute and array: (field_helpers - [:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each do |selector| -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2009 Feb 18
5
fields_for and Conflicting types for parameter containers. Expected an instance of Hash but found an instance of Array.
I''m trying to use ''fields_for'' in a form. I want the same form to support both the creation of new obejcts as well as the editing of old ones. So - in my controller, sometimes I will pass to the form an object that already exists in my database and has an id and other times I will pass it a newly created instance of an object that does not yet exist in the database and
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
2008 Jul 17
2
Final Opinion :: Need final opinions on the best way to handle arrays in forms
Hi There, rails noob just trying to suss a few things out. So I have 2 tables. 1 called Posts and the other called comments. On one page I need to be able to edit both the information about the post and the attributes of each comment for that post. So here is what the array might look like: (Inside the params hash) "post" => [ {"id"=>28, "title" =>
2010 Oct 15
1
Help with nested form: User and Artist
Artist is 1:1 with User. User has_one :artist In my artist model, I have: belongs_to :user accepts_nested_attributes_for :user However, in my artist _form, the name column from the user model does not display. I am doing: <% f.fields_for :user do |builder| %> <p class="fields"> <%= builder.label :name %> <%= builder.text_field :name %>
2008 Jan 25
1
form error with datetime select
Hi, Im trying to build a form using: <% facebook_form_for(:task, at task,:url => create_task_path) do |f| %> Assign Task To: <%= fb_friend_selector %> <%=f.text_field :ttype, :label=> "Title"%> <%=f.datetime_select :duedate, :label=> "Due Date"%> <%=f.buttons "Add" %> <% end %> But im getting an