Hi All,
I'm having severe issues with Rails, Javascript, and redirects. Basically I have the "simple" issue of redirecting to a different page if JS is disabled. If JS is enabled, then I add a new item inline immediately -- this works like a charm. However, if JS is disabled I want to redirect to the NEW page of a different controller. Basically the model setup is as such:
Site -> Buildings -> Controllers (not to be confused with Rails "controllers")
I have a "SiteManagerController" that uses JS to manage the whole thing. Basically I have a scenario where I'm trying to do the following:
1) if JS is enabled I want to add the item inline 2) if JS is disabled, I wish to render ":controller => buildings, :action => new"
My "link_to_remote" is straightforward. As I said, it works for JS. My rails controller code is as follows:
def add_building @building = Building.new @building.name = "Untitled" @building.site_id = params[:id] @building.save respond_to do |format| format.html {redirect_to :controller => "buildings", :action => "new"} format.js end end
This does not work. For what it's worth, when viewing page source there is no indication that anything is different when JS is enabled vs disabled. All links look the same -- i.e. Ajaxy.
I know it shouldn't be this complex an issue, but I'm rather stumped.
Best.
P.S. Please don't change the title of this post. ;)