Rendering a partial on a two column page

Hi,

I attached a page for clarity of what I want.

I have a two column page (index.html.erb). On the left hand side, I have the order ID and order NAME displayed. There is a SHOW link next to each entry.

I want to be able to click on the SHOW link and have it display the full order information on the right hand column (this is the show.html.erb file that Rails generated). I turned the default Rails generated show.html.erb file into a partial.

I'm sure this has to use link_to_remote on the SHOW link, but I'm not sure how to make it update the right hand column with the partial. I've read through a lot of the Rails API info jumping around to Helpers, remote_function and other things. I'm sure I'm missing something simple.

Any help would be appreciated.

Attachments: http://www.ruby-forum.com/attachment/4746/ScreenShot003.jpg

Okay, I made a really dumb mistake and put:

<% javascript_include_tag 'defaults' %>

Instead of:

<% javascript_include_tag :defaults %>

So that fixed my rendering. At least I'm getting information over to the other column now. But it's an error, because it can't find the ID. I attached the screenshot of the error I'm seeing. The following will be the code I currently have pertaining to this function. If anyone has any ideas on why it's throwing that error, I would really appreciate it (I know I'm missing something small here).

Here is my Show action in the Controller:

  def show     @order = Order.find(params[:id])

    respond_to do |format|       format.html # show.html.erb       format.xml { render :xml => @order }

    end   end

Okay, I made a really dumb mistake and put:

<% javascript_include_tag 'defaults' %>

Instead of:

<% javascript_include_tag :defaults %>

So that fixed my rendering. At least I'm getting information over to the other column now. But it's an error, because it can't find the ID. I attached the screenshot of the error I'm seeing. The following will be the code I currently have pertaining to this function. If anyone has any ideas on why it's throwing that error, I would really appreciate it (I know I'm missing something small here).

Here is my Show action in the Controller:

def show    @order = Order.find(params[:id])

   respond_to do |format|      format.html # show.html.erb      format.xml { render :xml => @order }

   end end

----

Here's the sections I have in my index.html.erb file:

     <% @orders.each do |order| %>        <tr>          <td><%=h order.id %></td>          <td><%=h order.name %></td>          <td><%= link_to_remote "Show", :url => {:controller => 'orders', :action => 'show',

   :id => order.id

}, :update => "order_div", :method => 'get' %></td>        </tr>      <% end %>

--

<div id="order_div">

</div>

----

Here is the info in the _order_show.html.erb partial:

<p> <b>Name:</b> <%=h @order.name %> </p>

<p> <b>Address:</b> <%=h @order.address %> </p>

<p> <b>City:</b> <%=h @order.city %> </p>

<p> <b>State:</b> <%=h @order.state %> </p>

<p> <b>Zip:</b> <%=h @order.zip %> </p>

.....ETC

Attachments: http://www.ruby-forum.com/attachment/4747/ScreenShot004.jpg

But you could also use a named route for the url. Something like order_path(order)

-Rob

Rob Biedenharn http://agileconsultingllc.com   Rob@AgileConsultingLLC.com

  rab@GaslightSoftware.com

Rob Biedenharn wrote:

Hi Rob,

Thanks for the quick response!

I'm sorry, I'm still relatively new at this Rails stuff. I have gone through a couple of books, but it's hard to tie it all together. :slight_smile:

When you put the following:

   :id => order.id

Where should I enter that? Within the link_to_remote somewhere?

Also, I would like to know the following. Not sure where I would enter that path in the link_to_remote:

But you could also use a named route for the url. Something like order_path(order)

Thanks again! I need all the help I can get. :slight_smile:

Rob Biedenharn wrote:

Hi Rob,

Thanks for the quick response!

I'm sorry, I'm still relatively new at this Rails stuff. I have gone through a couple of books, but it's hard to tie it all together. :slight_smile:

When you put the following:

  :id => order.id

Where should I enter that? Within the link_to_remote somewhere?

Yes, right where I put it:

        <td><%= link_to_remote "Show", :url => {:controller => 'orders', :action => 'show',

  :id => order.id

}, :update => "order_div", :method => 'get' %></td>

Also, I would like to know the following. Not sure where I would enter that path in the link_to_remote:

But you could also use a named route for the url. Something like order_path(order)

Thanks again! I need all the help I can get. :slight_smile:

<td><%= link_to_remote("Show", :url => order_path(order),                         :update => "order_div",                         :method => 'get') %></td>

-Rob

Rob Biedenharn http://agileconsultingllc.com   Rob@AgileConsultingLLC.com

  rab@GaslightSoftware.com

Thanks Rob!!! It worked PERFECTLY. Thanks again for you help!