开发者

How to get my rails pages to return as html?

I've written a rails site in the latest version of rails, based on knowledge of rails from a couple of years ago, and I've hit a horrible snag.

I foolishly decided to ignore the new RESTful routing system and hope for the best.

So all of my vie开发者_StackOverflowws are plain .erb, NOT html.erb

my routes file looks like this

map.connect '/crm/:action/:id', :controller => "contacts", :format => 'html'

here is an example of a method:

def update_emails
  Com.update_emails
  respond_to do |format|
    format.html {redirect_to(:action => 'list')}
  end
end

when it redirects to the 'list' action, I get a plain text file that my browser tries to download, instead of the html version of the page that I want.

Is there a simple way for me to tell rails to only send html format files?

Thank you!

EDIT:

list action

def list
  if params[:search]
    @contacts = Contact.search(params)
  else
    @contacts = Contact.find(:all, :order => "updated_at desc")
  end
end

and the view is a plain .erb file (problem is the same when I make it a .html.erb file)

Also, the same thing happens when I redirect_to other actions


You should use respond_to.

def update_emails
  Com.update_emails
  redirect_to(:action => 'list')
end

and then in the 'list' action

def list
  #some code here
  respond_to |format| do
    format.html {render :list}
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜