Howdy all.

I am creating an extension to make google maps in radiant easier but have come across an issue I cannot get my head around.

I have my GoogleMap model.

class GoogleMap < ActiveRecord::Base

 before_validation :create_point
 attr_accessor :latitude, :longitude

 private

 def create_point
   self.center = Point.from_x_y(self.latitude,self.longitude)
 end

end

Now, this center attribute is required on the DB level (I removed the validations to reduce points of possible failure). If I try and create a google map record in script/console it works fine.

>> gmap = GoogleMap.new
=> #<GoogleMap id: nil, name: nil, description: nil, center: nil, zoom: nil, created_at: nil, updated_at: nil>
>> gmap.name = "Console Test"
=> "Console Test"
>> gmap.description = "Created from the console"
=> "Created from the console"
>> gmap.latitude = 5
=> 5
>> gmap.longitude = 5
=> 5
>> gmap.zoom = 5
=> 5
>> gmap.save
=> true
>> gmap
=> #<GoogleMap id: 1, name: "Console Test", description: "Created from the console", center: #<GeoRuby::SimpleFeatures::Point:0xb6c51bb8 @y=5, @with_m=false, @x=5, @m=0.0, @with_z=false, @z=0.0, @srid=-1>, zoom: 5, created_at: "2009-01-19 16:16:15", updated_at: "2009-01-19 16:16:15">
>> gmap.center.x
=> 5
>> gmap.center.y
=> 5


However if I try it via the RadiantCMS interfact I just get kicked back to the create record page with no obvious information (and the fields blanked) and the create_point doesn't even get called if I debug it and stick a breakpoint in. No record gets saved and that is the end of that.

The controller is the simple one from the extension example

class Admin::MapsController < Admin::ResourceController
 model_class GoogleMap
end

Does anyone have any ideas?

Cheers

Jeff
_______________________________________________
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to