ruby-on-rails

find_all_by issues

I have rails application, which deals with some google map related stuff.the problem is , i have a table which contains latitude & longitude columns. the column types are "float". for some occasions i need to generate the query by the following: clients.find_all_by_lat_and_lng(latvalue,lngvalue). I gave the correct & existing lat & l...

How to delete a file in ruby which is still being used?

I am using spreadsheet gem to generate excel file. Now the problem with it is that when we modify an existing file it wont allow to save it with same name http://spreadsheet.rubyforge.org/GUIDE_txt.html and in the running script I cant delete and recreate the file beacause it is still being used. Doing so throws permission denied error. ...

Webbrick/Mongrel vs Passenger + Nginx for development?

Here is my case: For production I use Heroku. The question is what should i use for development: My alternatives are: Built in Webbrick (or Mongrel) Passenger with Nginx The question Im asking myself is: Why would I use the second alternative when I will upload my application to Heroku anyway. Isnt it better to just use Webbrick/...

Any reference material for fetching search results from retail sites?

If the question hasn't already done so, allow me to flag myself as a relative newcomer to backend programming. I'm really just wondering if anyone could point me to some literature on how to (for example) scrape the results of a search for "Die Hard" from amazon.com, and list them on your own page. Thanks in advance. ...

Replace Mongrel with Apache

I am new to Rails, so bear with me, I need to have apache tomcat as application server. How do i configure that by replacing the default Mongrel ...

Large image floating popup on mouseover

I'm looking at showing a large version of a thumbnail in a ruby on rails application when the user hovers over an image. The large version would be shown as a floating popup (near or at the mouse cursor) and disappear if the mouse moves away. When I say large image I'm talking about around 300x300 (where the thumbnails are under 100x100)...

How to know whether a model is new or not?

class Post < ActiveRecord::Base end post = Post.new How do I judge whether the 'post' is a new model which is not pulled from the database? ...

Ruby alternative for : <a href=http://jboss.org/drools>drools</a> a business logic integration platform.

Please suggest a ruby alternative for drools. It will be better if it also supports integration with rails Active Record. ...

How to avoid deprecation warning with named_scope (rails 2.X) / scope (rails 3) class_method

Hi, I build several plugins using the class method 'named_scope', which has been deprecated and replaced by 'scope' in Rails 3. I would like to avoid the following warning as I have lot a scopes present in my plugins : DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead. How to you deal with that?...

Inserting time into a time column with Ruby on Rails

Hello, I have run with a problem which i believe is Active Records fault. I am parsing an XML file which contains jobs. This xml file contains nodes which indicate walltime in the time format 00:00:00. I also have a model which will accept these jobs. However, when the time is larger than an actual 24H time, Active record inserts it as N...

factory_girl + rspec doesn't seem to roll back changes after each example

Similar to the problem described here: http://rpheath.com/posts/411-how-to-use-factory-girl-with-rspec in Short (shorten'd code): spec_helper: config.use_transactional_fixtures = true config.use_instantiated_fixtures = false factories.rb: Factory.define :state do f.name "NY" end in my spec before(:each) do @static_model = ...

Hook for gems to add middleware on the Rack stack with Rails 3

I am trying to find out how a gem in the Rails 3 gemfile can automatically add middleware to the Rack stack. I am looking for the hook in that gem. For example ... when I add the devise gem to my Rails 3 gemfile, then devise somehow adds warden as middleware on the Rack stack. This seems to work automatically. There is no further configu...

Authlogic performance? - Any request with SELECT *

Hi @ all I have a little performance issue with Authlogic - I dealed with them over days... and i can't figure out! The Problem is: I use the standard-Authlogic installation with following code in the application_controler to get the current_user (and to persits the session): def current_user_session return @current_user_session if ...

JSON or XML or serialized array to save in MySQL database

Web app. Get data from services in json & xml formats. And from internal module in hash. Decided to choose one format for all stored data. details : More read than write. Data low nested (< 10). Char count between 1000 - 100000. Programming language - ruby. Framework rails. DB mysql. What's your recommendation? ...

sh: irb not found error

Hi, i am very new to Ruby on rails . while running script/console , i am getting the below environment .. aruna@aruna-desktop:~/railsprojects/pagesapp$ script/console Loading development environment (Rails 2.3.8) sh: irb: not found Please give suggestions.. ...

clojure vs. Ruby

I'm ASP.NET developer. I want to learn web development technologies and other languages than Microsofts. I heard about two languages but I don't know which one is better or how to favor one over the other especially that clojure is new somehow. Could anyone help me about why to choose one of them over the other?. Thanks. ...

Application level filtering/data manipulation

I have a model with many different children (has_many). My app needs to lots of different manipulation on the who set of data. Therefore getting the data from the database is pretty simple, so I won't really need to use scopes and finders, BUT I want to do things on the data that are equivalent to say: named_scope :red, :conditions =>...

How do I check belongs_to model boolean field in a declarative_authorization file?

And again a decl_auth problem I want to achieve, that only active Users are allowed to view (:show) bookings model code User has_many :events has_many :bookings Event belongs_to :user has_many :bookings Booking belongs_to :event belongs_to :user # user.active => true in the authorization file has_permission_on [:b...

Creating migration through generator in ROR.

Hi, I am making an plugin in ROR and I want to make a migration file that will create a table. I am using generator for generating migration but not able to run it . So please tell me the exact process to create a migration through generators. Thanks! ...

How to unassign a value?

I have a table similar to the following id | name | address both name and address are not nullable(this i achieve through attribute setters only and not by default) When i create a new record without any default values what will be stored in the table? If the value is null -> if i store a value (say name="MyName", address="Th...