I am simply trying to show what the user enters somewhere else on the
page as they type it.

I did get it to work using render :text => param[:advert][:title] +
'<br/>' + param[:advert][:first_line] ......

But I think there should be a more efficient way to do it?

Could I do something like this:

def preview
  @advert = Advert.new(params[:advert])
  render :partial => 'advert'
end


Phil

On Mar 1, 7:31 pm, Frederick Cheung <[email protected]>
wrote:
> On Mar 1, 5:10 pm, phil7085 <[email protected]> wrote:
>
> > So then do I need to use the controller to populate another @advert
> > object with all the params then render the partial?
>
> Well I don't know exactly what this controller is trying to do at all.
> Assuming what it's doing is create a new object then the controller
> code is almost exactly the same as a regular create action, the only
> difference is that instead of redirecting to the show action you're
> rendering a partial for the  object you've just created.
>
> Fred
>
>
>
> > Cheers,
>
> > Phil
>
> > On Mar 1, 5:00 pm, Frederick Cheung <[email protected]>
> > wrote:
>
> > > On Mar 1, 1:04 pm, phil7085 <[email protected]> wrote:
>
> > > > I've been trying to create a simple form which when a user enters any
> > > > data that data is displayed as a preview elsewhere on the page
> > > > instantly, just like when creating an advert with Google Adwords, the
> > > > preview is shown.
>
> > > > I've been using form_remote_for and observe_form but I don't seem to
> > > > be having much luck at all. I am unsure how to use the controller to
> > > > get the form fields and pass them back to a partial to be rendered?
>
> > > In this respect it's much like a normal form, eg the title will be
> > > params[:advert][:title] (assuming @advert is of class Advert). As
> > > usual you can just looking at development.log to see what the
> > > parameters look like.
>
> > > Fred
>
> > > > Here is my form:
>
> > > > <% form_remote_for @advert do |a| %>
> > > > <label>Title:</label> <%= a.text_field :title %>
> > > > <br />
> > > > <label>First Line:</label> <%= a.text_field :first_line %>
> > > > <br />
> > > > <label>Second Line:</label> <%= a.text_field :second_line %>
> > > > <br />
> > > > <label>Visible URL:</label> <%= a.text_field :visible_url %>
> > > > <br />
> > > > <label>Destination URL:</label> <%= a.text_field :destination_url %>
> > > > <%= submit_tag 'Submit' %>
> > > > <% end %>
>
> > > > Any help would be great?
>
> > > > Cheers,
>
> > > > Phil- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to