Topic: How to modify form title?

Hello all!

Have been using rails the past 10 days, and am really enjoying it....

Just a small question. How does one modify/remove the title that Rails places in a scaffold-generated form when rendered. Say I have a model Expense, the edit form will have a title "New Expenses". I want to modify that to read "Expenses form". How do I do that.

Thanks!

Re: How to modify form title?

I am new to rails, but the way you modify the scaffolding is to actually generate it so that you have access to the files (otherwise each file is generated as needed by rails).

Use generate/scaffold model_name controller_name

This will place all the files into your structure and then you can edit them. The file you would be looking for would be in the views folder with the name of the action, so in your case prob edit.rhtml

This might be helpful: http://wiki.rubyonrails.org/rails/pages … rsions/new

-Bob

Re: How to modify form title?

i have gone as far as editing _form.rhtml. however, there is nothing in _form.rhtml which i can modify to change the title of the form.

any clue?

Re: How to modify form title?

The script is actually

script/generate scaffold [model_name]

The title of the page is defined in views/layouts/application.rhtml. For a page specific title, one solution is to assign it to an instance variable:

# in edit.rhtml
<% @title = "Expenses form" %>

# in application.rhtml
<title><%= @title || "Default Title" %></title>


Then it should display "Expenses form" in the title of the  edit form page.

Railscasts - Free Ruby on Rails Screencasts

Re: How to modify form title?

Thanks for your help....