On Aug 13, 2010, at 6:37 PM, Ruby on Rails: Talk wrote:
Thanks for the speedy reply.
I've tried ... <%= link_to "Add Photos", :controller
=> :entries, :action => :showphotos, :remote => true %>
I think you might be missing that there are two (2) hashes:
<%= link_to "Add Photos", {:controller=>:entries, :action=>:showphotos}, {:remote=>true} %>
The other answers that you're seeing use a named route for the second argument (which I'd recommend, too, but this might help you get going with a smaller step).
match '/entries/showphotos', :to => 'entries#showphotos', :as => 'showphotos'
<%= link_to "Add Photos", showphotos_path, :remote => true %>
-Rob
Which gives ... the following error:
ActionView::Template::Error (No route matches
{:action=>"showphotos", :remote=>true, :controller=>"entries"}):
6: <p>Date: <%= @entry.entrydate %><br>
7: Title: <%= @entry.title %><br>
8: Country: <%= @entry.country.name %></p>
9: <%= link_to "Add Photos", :controller => :entries, :action
=> :showphotos, :remote => true %>
10: <p>ADD OPTIONS TO DELETE AND EDIT AND OTHER SUCH EXCITING
THINGS HERE</p>
11: <div id="txtboxhead">
12: </div>
app/views/entries/show.rhtml:9:in
`_app_views_entries_show_rhtml___424117329_2183052120_0'
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0.rc/lib/
action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0.rc/lib/
action_dispatch/middleware/templates/rescues/_request_and_response.erb
(168.2ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0.rc/lib/
action_dispatch/middleware/templates/rescues/template_error.erb within
rescues/layout (173.2ms)
And if I change it to .... <%= link_to "Add Photos", :url =>
{:controller => :entries, :action => :showphotos}, :remote => true %>
I get the following ...
Started GET "/entries/1?
remote=true&url[action]=showphotos&url[controller]=entries" for
127.0.0.1 at Fri Aug 13 23:36:30 +0100 2010
Processing by EntriesController#show as HTML
Parameters: {"url"=>{"action"=>"showphotos",
"controller"=>"entries"}, "id"=>"1", "remote"=>"true"}
Entry Load (0.2ms) SELECT `entries`.* FROM `entries` WHERE
(`entries`.`id` = 1) LIMIT 1
Country Load (0.9ms) SELECT `countries`.`id`, `countries`.`name`,
`countries`.`created_at`, `countries`.`updated_at` FROM `countries`
WHERE (`countries`.`id` = 10) LIMIT 1
Photo Load (0.3ms) SELECT `photos`.`id`, `photos`.`entry_id`,
`photos`.`created_at`, `photos`.`updated_at`,
`photos`.`data_file_name`, `photos`.`data_content_type`,
`photos`.`data_file_size`, `photos`.`data_updated_at`,
`photos`.`data_comment` FROM `photos` WHERE (`photos`.entry_id = 1)
Rendered entries/show.rhtml within layouts/application (103.0ms)
Completed 200 OK in 116ms (Views: 106.0ms | ActiveRecord: 1.4ms)
Which still suggest the controller/action is not being run ...
I'm still none the wiser!
Any clarification?
Thanks
Darren
On Fri, Aug 13, 2010 at 5:17 PM, Ruby on Rails: Talk
I'm trying to replicate the following in Rails 3:
<%= link_to_remote image_tag("creditcard.png", :border => 0), :url =>
{:action => :make_payment, :type => "Credit", :id =>
@appt.id }, :with=>"'amount='+$F('amount')", :complete =>
remote_function( :url => { :action => :load_appt, :id => @appt.id })
%>
link_to 'foo', some_path, :remote => true
--
Greg Donald
destiney.com | gregdonald.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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Rob Biedenharn
Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/
rab@GaslightSoftware.com http://GaslightSoftware.com/