Abhishek shukla
2009-Dec-07 08:05 UTC
accepts_nested_attributes_for + paperclip + polymorphic + problem
Hello Friends, I am not able to retrieve the value form page controller offices_controller def new @office = Office.new end def create @office = Office.new(params[:office]) @office.save end end VIEW <% form_for @office do |f| %> <%= f.text_area :office_name %> <% f.fields_for :images_attributes do |i| %> <%= i.file_field :avatar %> <%end%> <%= f.submit "Submit" %> <%end%> Model Office.rb accepts_nested_attributes_for :image Image.rb belongs_to :imagable, :polymorphic => true PROBLEM When I press submit, the params[:office] only contain :office_name and avatar is getting lost? I don;t know where excatly I am getting wrong. Thanks for any suggestion Abhis -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Antony Sastre
2009-Dec-07 12:41 UTC
Re: accepts_nested_attributes_for + paperclip + polymorphic + problem
Hi Ab, The form view should read: <% form_for @office, :html => {:multipart => true} do |f| %> This is always the case when dealing with file uploads. On Dec 7, 9:05 am, Abhishek shukla <bettera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello Friends, > > I am not able to retrieve the value form page > > controller > offices_controller > def new > @office = Office.new > end > > def create > @office = Office.new(params[:office]) > -XGtdSYsFI3XfhZSSa7DgLw@public.gmane.org > end > end > > VIEW > <% form_for @office do |f| %> > <%= f.text_area :office_name %> > <% f.fields_for :images_attributes do |i| %> > <%= i.file_field :avatar %> > <%end%> > <%= f.submit "Submit" %> > <%end%> > > Model > > Office.rb > accepts_nested_attributes_for :image > > Image.rb > belongs_to :imagable, :polymorphic => true > > PROBLEM > When I press submit, the params[:office] only contain :office_name and > avatar is getting lost? I don;t know where excatly I am getting wrong. > > Thanks for any suggestion > > Abhis-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Abhishek shukla
2009-Dec-08 06:04 UTC
Re: Re: accepts_nested_attributes_for + paperclip + polymorphic + problem
antony thanks. It worked,. On Mon, Dec 7, 2009 at 6:11 PM, Antony Sastre <cubalife-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Ab, > > The form view should read: > > <% form_for @office, :html => {:multipart => true} do |f| %> > > This is always the case when dealing with file uploads. > > > On Dec 7, 9:05 am, Abhishek shukla <bettera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello Friends, > > > > I am not able to retrieve the value form page > > > > controller > > offices_controller > > def new > > @office = Office.new > > end > > > > def create > > @office = Office.new(params[:office]) > > @office.save > > end > > end > > > > VIEW > > <% form_for @office do |f| %> > > <%= f.text_area :office_name %> > > <% f.fields_for :images_attributes do |i| %> > > <%= i.file_field :avatar %> > > <%end%> > > <%= f.submit "Submit" %> > > <%end%> > > > > Model > > > > Office.rb > > accepts_nested_attributes_for :image > > > > Image.rb > > belongs_to :imagable, :polymorphic => true > > > > PROBLEM > > When I press submit, the params[:office] only contain :office_name and > > avatar is getting lost? I don;t know where excatly I am getting wrong. > > > > Thanks for any suggestion > > > > Abhis > > -- > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
andresgutgon
2009-Dec-19 01:40 UTC
Re: accepts_nested_attributes_for + paperclip + polymorphic + problem
Thanks, it worked for me to :D On Dec 7, 1:41 pm, Antony Sastre <cubal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Ab, > > The form view should read: > > <% form_for @office, :html => {:multipart => true} do |f| %> > > This is always the case when dealing with file uploads. > > On Dec 7, 9:05 am, Abhishek shukla <bettera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello Friends, > > > I am not able to retrieve the value form page > > > controller > > offices_controller > > def new > > @office = Office.new > > end > > > def create > > @office = Office.new(params[:office]) > > -XGtdSYsFI3XfhZSSa7DgLw@public.gmane.org > > end > > end > > > VIEW > > <% form_for @office do |f| %> > > <%= f.text_area :office_name %> > > <% f.fields_for :images_attributes do |i| %> > > <%= i.file_field :avatar %> > > <%end%> > > <%= f.submit "Submit" %> > > <%end%> > > > Model > > > Office.rb > > accepts_nested_attributes_for :image > > > Image.rb > > belongs_to :imagable, :polymorphic => true > > > PROBLEM > > When I press submit, the params[:office] only contain :office_name and > > avatar is getting lost? I don;t know where excatly I am getting wrong. > > > Thanks for any suggestion > > > Abhis > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.