On Thu, Jun 17, 2010 at 9:51 PM, Sharkie Landshark <li...@ruby-forum.com>wrote:

> I have been using link_to_remote forever now. I have also been using
> jquery through jrails.
>
> I am readying my code for Rails 3.0, and am wondering what is the best
> way to accomplish.
>
> For example, I have something like this all over in Rails 2.0
>
> <%= link_to_remote "XXX",
>                      { :url => "/activities/hide_dock", :update =>
> "dock-container", :complete => "fixDock()" }, { :class => "activities" }
>  %>
>
>
Sharkie, I would recommend reading the following first before you start
upgrading from Rails 2.x to Rails 3.x:

http://blog.peepcode.com/tutorials/2010/live-coding-rails-3-upgrade

Next, link_to_remote has been deprecated in Rails 3 and you would
need to do the following:

<%= link_to "XXX", { :remote => true }, { ... } %>


> def hide_dock
>  render :partial => "/layouts/dock"
> end
>
> Now, in Rails 3.0 I am planning this
>
> <%= raw link_to "XXX", "/activities/hide_dock",
>                      {:remote => true, :class => "activities" }
>  %>
>
>
Next, the above shouldn't use raw because link_to method
returns an html_safe string in Rails 3.


> def hide_dock
>  respond_to do |format|
>    format.html
>      format.js do
>        ????? What do I put here ?????
>

If you're using RJS, then you'll simple add
the expression to be executed.  For example,
I tend to be partial to JSON and I would do the
following:

format.js # render the action.js.rjs by default

or you can redefine it as follows to return json

format.js { render :json => @some_object }


>      end
>    end
> end
>
>
It's not clear as to what you're trying to do.  The hide_dock is a
controller
action so do you want to allow the following:

http://some_domain.com/controller_name/hide_dock


> My main question is since I am using jQuery, is there any point in using
> RJS?
>
>
If you intend on using jQuery, then there's no need to use RJS.  Just make
sure that you get the JS file here:

http://github.com/rails/jquery-ujs


> Should I just have
>
> render :layout => false
>
>
If you're updating just a part of the page, then you'll need to use the
above.


> and in hide_dock.js.erb just use jQuery code with <%= render :partial
> =>%> where appropriate.
>

Lastly, I would recommend getting the PDF for "Agile Web Development with
Rails 4th Ed" by Sam Ruby, Dave Thomas, et al from pragprog.com for
additional
information regarding the questions that you have above.

Good luck,

-Conrad


> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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 rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to