@location in the show method of the locations controller will contain
the instance, but only after Hobo has had a chance to do that for you.

Here's a few possibilities.   I think for you all three will work, but
for others the order might be important.

def show
  hobo_show
  @json = @location...
end

def show
  hobo_show do
     @json = @location...
  end
end

def show
  @location = find_instance
  @json = ...
   hobo_show
end


Bryan

On Tue, Jan 15, 2013 at 12:04 PM,  <[email protected]> wrote:
> Hi,
> I'm puzzled and any help would be much appreciated.  I'm using gmaps4rails
> successfully.  If I want to show all of the records, that works fine.  This
> working code is commented out below.  Where I'm having problems is when I
> only want to show the current record.  My understanding from the hobo
> documentation was that @location would provide access to the current record.
>
> "As well as setting the default DRYML context, the default actions all make
> the record, or collection of records, available to the view in an instance
> variable that follows Rails conventions. E.g. for a  ̳product‘ model, the
> product will be available as @product and the collection of products on an
> index page will be available as @products" -- Rapid Rails 3 with Hobo
> BETA-6: 2011-05-18 page 380
>
>
> class LocationsController < ApplicationController
>   hobo_model_controller
>   auto_actions :all
>
>   def show
>     #@json = Location.all.to_gmaps4rails    <--- Works, but get all records
> instead of current
>
>     @json = @location.to_gmaps4rails       #<--- Thought this would have
> worked, but fails
>
>     #@json1 = Array.new
>     #@json1 << @location
>     #@json = @json1.all.to_gmaps4rails     <--- Tried this as a workaround,
> but it fails also
>
>     hobo_show
>   end
> end
>
>
> Error Log:
> NoMethodError (You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.to_gmaps4rails):
>   app/controllers/locations_controller.rb:16:in `show'
>
> Rendered
> /usr/local/rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb
> (1.5ms)
> Rendered
> /usr/local/rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
> (23.2ms)
> Rendered
> /usr/local/rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
> within rescues/layout (29.4ms)
>
>
> Gems (partial list):
> *** LOCAL GEMS ***
> activerecord (3.2.10, 3.2.9, 3.0.18, 3.0.17, 3.0.12, 3.0.10, 2.3.14)
> activeresource (3.2.10, 3.2.9, 3.0.18, 3.0.17, 3.0.12, 3.0.10, 2.3.14)
> activesupport (3.2.10, 3.2.9, 3.0.18, 3.0.17, 3.0.12, 3.0.10, 2.3.14)
> dryml (1.3.3, 1.3.2, 1.3.0)
> gmaps4rails (1.5.6)
> hobo (1.3.3, 1.3.0, 1.0.1)
> hobo_fields (1.3.3, 1.3.2, 1.3.0)
> hobo_support (1.3.3, 1.3.2, 1.3.0)
> hobofields (1.1.0, 1.0.1)
> hobosupport (1.1.0, 1.0.1)
> rails (3.0.10, 2.3.14)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/dbHNgVoRi14J.
> 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/hobousers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.

Reply via email to