Thanks for the advice Rob and SOOOO sorry to keep harping on about
this ... but I've tried:

<%= link_to "Add Photos", {:controller => 'entries', :action =>
'showphotos'}, {:remote => true} %>

and

<%= link_to "Add Photos", {:controller => :entries, :action
=> :showphotos}, {:remote => true} %>

and both times I'm getting the following error:

Showing /Users/dazzaroonie/Sites/newwt/app/views/entries/show.rhtml
where line #9 raised:

No route matches {:controller=>"entries", :action=>"showphotos"}
Extracted source (around line #9):

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>

Which is rubbish as the following the entries controller:

class EntriesController < ApplicationController

  def show
    @entry = Entry.find(params[:id])
  end

  def new
    @countries = Country.find(:all, :order => :name)
    @entry = Entry.new
  end

  def create
    @entry = Entry.new(params[:entry])
    if @entry.save
      flash[:notice] = "Successfully saved the Entry"
      redirect_to entry_path(@entry)
    else
      redirect_to :new
    end
  end

  def showphotos
    logger.warn("I am here")
  end

end

I'm going to end up in the nut house soon lol.

Any further ideas?

On Aug 14, 8:14 pm, Rob Biedenharn <r...@agileconsultingllc.com>
wrote:
> 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 Aug 13, 11:28 pm, Greg Donald <gdon...@gmail.com> wrote:
> >> On Fri, Aug 13, 2010 at 5:17 PM, Ruby on Rails: Talk
>
> >> <dazzaroo...@gmail.com> wrote:
> >>> 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-
> > t...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > rubyonrails-talk+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en
> > .
>
> Rob Biedenharn          
> r...@agileconsultingllc.com        http://AgileConsultingLLC.com/
> r...@gaslightsoftware.com          http://GaslightSoftware.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.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to