I have this in my shop.rb:
def geocode_address
if !address_geo.blank?
geo=Geokit::Geocoders::MultiGeocoder.geocode(address_geo)
errors.add(:address, "Could not Geocode address") if !geo.success
self.lat, self.lng = geo.lat,geo.lng if geo.success
end
end
# Checks whether this object has been geocoded or not. Returns the ...
I'm attempting to render xml from a service application.
In the model, the relationship is defined as:
class Customer < ActiveRecord::Base
has_many :licenses
accepts_nested_attributes_for :licenses
end
In my Controller, I have the following code:
if @customer.save
render :xml => @customer, :status => :created
else
re...
Hi All,
In our application we are storing some views (.erb files) in public/custom_themes/{user}/ folders. We have tried to add the path RAILS_ROOT to view_paths and specifying the /custom_themes/{user}/theme.erb in render :layout. In development environment it works fine, but in production it takes ages to find the views. It did find b...
Just to simplify my question here: Update Geocode latitude and logitude everytime address is updated
I wanna do this:
Two input field for user to enter values for A, B. When it is saved, value A and B are saved to the database. In the database column, there is a column C, which dynamically C = A + B.
First save:
A = 1
B = 2
C = A + B...
Scenario: I have a dropdown-list with radiobuttons, that are not required to be selected to submit the form, and after I've chosen an option, from there on it's impossible to deselect it. I want it to be possible somehow.
Thoughts for solutions:
1) Implement some feature that enables you to deselect the radiobutton, much like a checkbox...
Sorry if the question is obvious, I am only starting to work with Rails.
I have a following code in several controller methods now:
respond_to do |format|
if @project.save
format.html { redirect_to(edit_project_url(@project), :notice => '#{user.name} added to #{role}.') }
format.js
else
format.html { rend...
Hello,
I have the following:
@books.each do |book|
... stuff
end
I'm curious to learn. How can I update the above to do something like loop through @books but not more than 6 times, MAX/ceiling of 6?
Thanks
...
I'm a bit confused about timezones in rails. I want my rails app to use British Summer Time (like daylight savings in the US) for the timestamps set in updated_at and created_at in my models. I changed my environment.rb to say
config.time_zone = 'London'
The ubuntu server my app is on seems to use BST for it's time: in the comman...
Hi,
I have a problem to find a way to save an image created with RMagick in a paperclip attachment.
imageList = Magick::ImageList.new
imageList.new("images/apple.gif", "images/overlay.png")
...
picture = imageList.flatten_images
I am in a model that have an attached file
has_attached_file :picture,
:url => ...,
:path => ...
...
Hi,
In a RoR application, I would like to load a set of key/values from db into a global variable which persists across requests and clear the variable as and when I need. My application runs in a WAS cluster. I tried a few things. 1. Used memcachestore and read/write/clear as needed. 2. Load the key/values in a yaml file and clear it w...
I would like to render a hash into json, where elements in the json array are the result of link_to some_path(@object) calls and such, and am wondering how to do this the Rails way.
class PostController
def index
@posts = Post.to_flexigrid(params)
# @posts == {:page => 1, :count => 102, :rows => [{:cell => #<Post...>}...]}.to_...
Hello all,
In my app, I have three models: Markets, Deals, and Users. Relationships are pretty straightforward:
class Market
has_many :users
has_many :deals
end
class User
belongs_to :market
end
class Deal
belongs_to :market
end
Now, in order to more easily query some of those relationships, the Market model has some metho...
Hi all
I have to make a web call which will take a file from the user and post it to the server.
i am new to web so what should mt url be like.
i tried http//www.example.com?param[id]=1
so what should the next parameter be which will take uploaded file data.
i think he has to give me the binary data of the file
thanks in advance
...
I'm looking to debug a delayed jobs class. First off I added the config/initializers/delayed_job_config to move my logging to my log/production.rb file.
Delayed::Job.destroy_failed_jobs = false
Delayed::Worker.logger = Rails.logger
Then in the actual file I'm doing in the actual file
class TestJob < Struct.new()
logger.debug("test ...
So one week ago I started to move my old app written in Rails 2.3.5 to new 3.0. Unfortunately, I found out that some of the views are loading surprisingly slow.
Example:
Rails 2.3.5 Ruby 1.8.7 -> WEBrick: Completed in 297ms (View: 143, DB: 40)
Rails 3.0.0 Ruby 1.8.7 -> WEBrick: Completed in 3081ms (View: 261, ActiveRecord: 108)
Rails ...
Hi, I'm trying to install Abingo for my Rails application which seems can only be installed as a plugin, but it consistently fails silently with just an empty folder created.
I've installed plugins in the past (although not on this app, with another in my InstantRails folder), but for some reason today nothing is installing at all, and ...
I installed Devise today and everything works fine so far. The only thing devise seems not to offer is a 'registration#show' action, which displays the user information (instead of the registration edit page). I tried to override the registrations-controller, but get the error: 'Unknown action-AbstractController::ActionNotFound' for all ...
I've noticed on viewing the source of my Rails app that a lot of information is publicly available that shouldn't be - specifically a Google Analytics script that contains my GA account number, and the authenticity tokens for my forms.
Are there any guidelines on hiding this kind of code in the source?
...
I have a startup considering building a Java backend and a Rails frontend. The Java backend will take care of creating a caching layer for the database and offer other additional services. The Rails frontend will mostly be for creating the webapp and monitoring tools.
What startups/companies out there are using this kind of setup? What ...
I've been searching the internet without success, looking for info on acts_as_ferret. The few pages I've found show methods that apparently doesn't exist any more (my rails app show me the "method not found error", and the docs in the acts_as_ferret page are very scarce. Anyone have a good tutorial or API docs about this plugin?
...