Re: [Rails] Rspec: How to test create action in controller
On Sun, Jan 13, 2013 at 9:17 AM, Jordon Bedwell <envygeeks@gmail.com> wrote:
> MyController < ApplicationController
> def my_action
> redirect_to :back unless params["blah"] == "blah"
> render :my_template
> end
> end
>
> Should be:
>
> MyController < ApplicationController
> def my_action
> return redirect_to :back unless params["blah"] == "blah"
> render :my_template
> end
> end
To add before somebody points it out, I would never personally write a
simple method like that, I would instead prefer to do something like:
MyController < ApplicationController
def my_action
prams["blah"] == "blah" ? render(:my_template) : redirect_to(:back)
end
end
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home