Nathan Sharkey
2008-Mar-06 14:23 UTC
splitting up data for input (multiple controllers one model?
hi, I have a model detailing companies and i would like to split up the data entry into different views. for instance company profile, contact etc. so they can create a company then edit the various field using different views. I assumed the best way to do this is create a controller for each view? I have tried this with profile but i get no joy, it won''t update the records attributes but throws no errors, it does populate the fields with existing data in the edit view so edit action is correct. here''s my code have tried error_messages_for to :profile or :company but i get no errors #views/profiles/edit.html.erb <%= error_messages_for :profile %> <% form_for :profile do |f| %> <p><label for="profile">Profile</label><br/> <%= f.text_area :profile, :cols =>"80", :rows => "20" %></p> <p><%= f.submit ''Update'' %></p> <% end %> class ProfilesController < ApplicationController before_filter :login_required # GET /profiless/1/edit def edit @profile = Company.find(@current_company.id) end # PUT /profiles/1 # PUT /profiles/1.xml def update @profile = Company.find(params[:id]) respond_to do |format| if @profile.update_attributes(params[:company]) flash[:notice] = ''profile was successfully updated.'' format.html { redirect_to(@profile) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @profile.errors, :status => :unprocessable_entity } end end end cheers Nathan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nathan Sharkey
2008-Mar-06 14:28 UTC
Re: splitting up data for input (multiple controllers one mo
> if @profile.update_attributes(params[:company])ps this line should read :profile not :company. still doesn''t work though :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Mar-06 16:12 UTC
Re: splitting up data for input (multiple controllers one model?
On 6 Mar 2008, at 14:23, Nathan Sharkey wrote:> > here''s my code > > have tried error_messages_for to :profile or :company but i get no > errors > > #views/profiles/edit.html.erb > <%= error_messages_for :profile %> > > <% form_for :profile do |f| %> > > <p><label for="profile">Profile</label><br/> > <%= f.text_area :profile, :cols =>"80", :rows => "20" %></p>This implies the data will be in params[:profile]> > if @profile.update_attributes(params[:company])but here you''re using params[:company] Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Mar-06 16:13 UTC
Re: splitting up data for input (multiple controllers one model?
On 6 Mar 2008, at 16:12, Frederick Cheung wrote:> > On 6 Mar 2008, at 14:23, Nathan Sharkey wrote: >> >> here''s my code >> >> have tried error_messages_for to :profile or :company but i get no >> errors >> >> #views/profiles/edit.html.erb >> <%= error_messages_for :profile %> >> >> <% form_for :profile do |f| %> >> >> <p><label for="profile">Profile</label><br/> >> <%= f.text_area :profile, :cols =>"80", :rows => "20" %></p> > > This implies the data will be in params[:profile] >> >> if @profile.update_attributes(params[:company]) > but here you''re using params[:company] >Oops, hadn''t read your second mail :-) Sorry> Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---