If I don''t want xml results but only html can I omit respond_with in some actions? For example index from: respond_with(@sectors = Sector.all) becomes only @sectors = Sector.all isn''t it? -- 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.
Yes, you can omit respond_with. Most of my apps are entirely without respond_with calls unless I have an explicit need for xml, etc.> ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 3:02 PM > > > If I don''t want xml results but only html can I omit respond_with in > some actions? > For example index from: > respond_with(@sectors = Sector.all) > becomes only > @sectors = Sector.all > > isn''t it? >-- 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.
On 11 January 2011 22:14, Garrett Lancaster <glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org>wrote:> Yes, you can omit respond_with. Most of my apps are entirely without > respond_with calls unless I have an explicit need for xml, etc. >If I omit respond_with in some actions like create and destroy raise an error of missing template. -- 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.
If you don''t provide a redirect_to, it will assume a view with name create.html.erb or create.html.haml, etc. and try to render it giving you a missing template. The most common design is create redirects to @model and destroy redirects to index_path. Garrett Lancaster> ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 3:58 PM > > > > > Yes, you can omit respond_with. Most of my apps are entirely > without respond_with calls unless I have an explicit need for xml, > etc. > > > If I omit respond_with in some actions like create and destroy raise > an error of missing template. > -- > 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. > ------------------------------------------------------------------------ > > Garrett Lancaster <mailto:glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> > January 11, 2011 3:14 PM > > > Yes, you can omit respond_with. Most of my apps are entirely without > respond_with calls unless I have an explicit need for xml, etc. > > ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 3:02 PM > > > If I don''t want xml results but only html can I omit respond_with in > some actions? > For example index from: > respond_with(@sectors = Sector.all) > becomes only > @sectors = Sector.all > > isn''t it? >-- 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.
On 11 January 2011 23:02, Garrett Lancaster <glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org>wrote:> If you don''t provide a redirect_to, it will assume a view with name > create.html.erb or create.html.haml, etc. and try to render it giving you a > missing template. The most common design is create redirects to @model and > destroy redirects to index_path. >If I put in create respond_with, for example respond_with(@sector) it seems that redirects automatically to show while respond_with(@sector) in destroy redirects to index. How can it know where redirect? -- 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.
defcreate @user = User <http://apidock.com/rails/User>.new <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) flash[:notice] = ''User was successfully created.'' if @user.save respond_with(@user) end is the same as: defcreate @user = User <http://apidock.com/rails/User>.new <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) respond_to do |format| if @user.save flash[:notice] = ''User was successfully created.'' format.html { redirect_to(@user) } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { render :action => "new" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end It''s just built into the method. Garrett Lancaster> ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 4:11 PM > > > > > If you don''t provide a redirect_to, it will assume a view with > name create.html.erb or create.html.haml, etc. and try to render > it giving you a missing template. The most common design is > create redirects to @model and destroy redirects to index_path. > > > If I put in create respond_with, for example respond_with(@sector) it > seems that redirects automatically to show while respond_with(@sector) > in destroy redirects to index. > How can it know where redirect? > -- > 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. > ------------------------------------------------------------------------ > > Garrett Lancaster <mailto:glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> > January 11, 2011 4:02 PM > > > If you don''t provide a redirect_to, it will assume a view with name > create.html.erb or create.html.haml, etc. and try to render it giving > you a missing template. The most common design is create redirects to > @model and destroy redirects to index_path. > > Garrett Lancaster > > ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 3:58 PM > > > > > Yes, you can omit respond_with. Most of my apps are entirely > without respond_with calls unless I have an explicit need for xml, > etc. > > > If I omit respond_with in some actions like create and destroy raise > an error of missing template. > -- > 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. > ------------------------------------------------------------------------ > > Garrett Lancaster <mailto:glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> > January 11, 2011 3:14 PM > > > Yes, you can omit respond_with. Most of my apps are entirely without > respond_with calls unless I have an explicit need for xml, etc. > > ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 3:02 PM > > > If I don''t want xml results but only html can I omit respond_with in > some actions? > For example index from: > respond_with(@sectors = Sector.all) > becomes only > @sectors = Sector.all > > isn''t it? >-- 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.
On 11 January 2011 23:45, Garrett Lancaster <glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org>wrote:> def create > @user = User <http://apidock.com/rails/User>.new <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) > flash[:notice] = ''User was successfully created.'' if @user.save > respond_with(@user) > end > > is the same as: > > def create > @user = User <http://apidock.com/rails/User>.new <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) > > respond_to do |format| > if @user.save > flash[:notice] = ''User was successfully created.'' > format.html { redirect_to(@user) } > format.xml { render :xml => @user, :status => :created, :location => @user } > else > format.html { render :action => "new" } > format.xml { render :xml => @user.errors, :status => :unprocessable_entity } > end > end > end > > It''s just built into the method. > >where did you get this information? -- 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.
Google for respond_with: http://apidock.com/rails/ActionController/MimeResponds/respond_with Garrett Lancaster> ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 12, 2011 2:34 AM > > > > > def create > @user = User <http://apidock.com/rails/User>.new > <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) > flash[:notice] = ''User was successfully created.'' if @user.save > respond_with(@user) > end > > is the same as: > > def create > @user = User <http://apidock.com/rails/User>.new > <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) > > respond_to do |format| > if @user.save > flash[:notice] = ''User was successfully created.'' > format.html { redirect_to(@user) } > format.xml { render :xml => @user, :status => :created, :location > => @user } > else > format.html { render :action => "new" } > format.xml { render :xml => @user.errors, :status => > :unprocessable_entity } > end > end > end > > It''s just built into the method. > > > where did you get this information? > -- > 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. > ------------------------------------------------------------------------ > > Garrett Lancaster <mailto:glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> > January 11, 2011 4:45 PM > > > def create > @user = User <http://apidock.com/rails/User>.new > <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) > flash[:notice] = ''User was successfully created.'' if @user.save > respond_with(@user) > end > > is the same as: > > def create > @user = User <http://apidock.com/rails/User>.new > <http://apidock.com/rails/ActionController/Responder/new/class>(params[:user]) > > respond_to do |format| > if @user.save > flash[:notice] = ''User was successfully created.'' > format.html { redirect_to(@user) } > format.xml { render :xml => @user, :status => :created, :location => > @user } > else > format.html { render :action => "new" } > format.xml { render :xml => @user.errors, :status => > :unprocessable_entity } > end > end > end > > It''s just built into the method. > > Garrett Lancaster > > > ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 4:11 PM > > > > > If you don''t provide a redirect_to, it will assume a view with > name create.html.erb or create.html.haml, etc. and try to render > it giving you a missing template. The most common design is > create redirects to @model and destroy redirects to index_path. > > > If I put in create respond_with, for example respond_with(@sector) it > seems that redirects automatically to show while respond_with(@sector) > in destroy redirects to index. > How can it know where redirect? > -- > 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. > ------------------------------------------------------------------------ > > Garrett Lancaster <mailto:glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> > January 11, 2011 4:02 PM > > > If you don''t provide a redirect_to, it will assume a view with name > create.html.erb or create.html.haml, etc. and try to render it giving > you a missing template. The most common design is create redirects to > @model and destroy redirects to index_path. > > Garrett Lancaster > > ------------------------------------------------------------------------ > > Mauro <mailto:mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 3:58 PM > > > > > Yes, you can omit respond_with. Most of my apps are entirely > without respond_with calls unless I have an explicit need for xml, > etc. > > > If I omit respond_with in some actions like create and destroy raise > an error of missing template. > -- > 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.-- 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.
On 12 January 2011 17:34, Garrett Lancaster <glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org>wrote:> Google for respond_with: > http://apidock.com/rails/ActionController/MimeResponds/respond_with >Didn''t know apidock.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-/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.
Msan Msan wrote in post #974376:> On 12 January 2011 17:34, Garrett Lancaster > <glancast-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org>wrote: > >> Google for respond_with: >> http://apidock.com/rails/ActionController/MimeResponds/respond_with >> > > Didn''t know apidock.com.I find http://www.railsapi.com a lot more attractive, but APIdock has a couple of cool features. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/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.