Re: Set a select box with default value selected

deostroll
Mon, 21 Sep 2009 19:15:11 -0000

How do I re-write the new.html.erb?

On Sep 15, 12:02 am, "Pardee, Roy"
<parde...-go57ItdSaco@public.gmane.org> wrote:
> Something like...
>
> # views/subject/show
>   <%= link_to ''Would you like to add one?'',
new_book_path, {:subj => @subject} %>
>
> # controllers/books_controller
>   def new
>     @book = Book.new
>     @book.subject = params[:subj]
>     # etc...
>   end
>
> HTH,
>
> -Roy
>
> -----Original Message-----
> From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of deostroll
> Sent: Monday, September 14, 2009 1:08 PM
> To: Ruby on Rails: Talk
> Subject: [Rails] Set a select box with default value selected
>
> I am relating to the book & subject example mentioned in the tutorial
mentioned here:
>
> http://www.tutorialspoint.com/ruby-on-rails-2.1/rails-examples.htm
>
> There is a file that goes like show_subjects.html.erb and it will list all
the books for that particular subject we''ve selected.
>
> Suppose if there were no books to show for the subject we can ideally show
a corresponding message like "there are no books for this subject yet"
>
> I''d like to rewrite that is "there are no books for this
subject, would you like to add one?"
>
> Lets say that the ''would you like to add'' part is a link
to the book create view where in we add a book. How do I load that page to have
its select box show the subject tht had no books (from where I was initially
at)...?
>
> --deostroll
>
> GHC Confidentiality Statement
>
> This message and any attached files might contain confidential information
protected by federal and state law. The information is intended only for the use
of the individual(s) or entities originally named as addressees. The improper
disclosure of such information may be subject to civil or criminal penalties. If
this message reached you in error, please contact the sender and destroy this
message. Disclosing, copying, forwarding, or distributing the information by
unauthorized individuals or entities is strictly prohibited by law.