How do I redirect_to a certain path or page inside the view. I’ve read that redirect_to is an ActionController something, and cannot be used in the view. How can I do this in the view using only Rails, and how can I in addition to this write the redirection inside the controller or the model or helper and then just writing in the instance variable inside the view. I am using Devise. I do not want to use Javascript nor JQuery. Just Rails!
I tried this:
class Post < ActiveRecord::Base
attr_accessible :content, :title
@Uchecker = user_signed_in?
redirect_to user_session-path
end
When you use the *redirect_to* from a controller, instead of rendering a view, what it does is to render an http redirect
Now if you want to do a redirection from the view, you can still use javascript
Not the best practice but it works, and its a common practice for intermediate pages (i.e. when you search for a trip, the trip search could take like 60 seconds, so you render a view where you show something to the user like you are searching for the best trip, and you do a javascript redirection, once the result is ready, the page is loaded).