ruby-on-rails

Forcing rails to create asset cache files

I am hosting my assets on s3. In production, rails is looking for /javascripts/cache/all.js and /stylesheets/cache/all.css. I'm using a plugin to swoop the public directory over to s3 when I deploy with cap. The problem is that rails doesn't create these cache files until they are requested for the first time, so they aren't around du...

What steps are followed after you say "rake install"?

I'd like to install a plugin but I'm afraid it's going to install a lot of unnecessary stuff. I'd like to look at whatever file rake takes it installation instructions from and remove anything unnecessary. I believe this is the Rakefile. But I'm not sure what happens when rake looks at the rakefile - does it execute the entire rakefile ...

Rails for ecommerce site

I was planning on using RoR for an upcoming e-commerce site but keep reading comments that give the impression that this framework is not yet fit for this type of a commercial application. What is the state of it? May it be used for large scale online stores etc? Is compatibility and the frequently changing framework an issue to worry ...

Setting a cookie before Javascript Redirection

Hello, I have a Rails app where I set a set a session variable the moment a user lands on my site with the referer and the page they hit. Additionally, I have Google Optimizer sending traffic from my homepage to various landing pages. The problem is that I think Google Optimizer is sending users away before the cookie is set. Is t...

Is there a ready made RMagick image editor out there?

I am about to build a basic online image editor for my web application using rails and rmagick. I did a bit of googling but couldn't find any existing solution, however I'd like to be sure before I spend a lot of time rolling my own. Is anyone aware of a plugin/gem that provides a pre-rolled image editor with undo/redo and minimal image...

Ruby on Rails, Low Pro, and JQuery (through JRails)

Hello peoples, I am using JRails with Ruby on Rails so that I can simply use jQuery since I am more familiar with it. I am also attempting to use Low Pro to submit some of my forms remotely. I am currently running into an interesting problem that has me stumped. I have added the following to my application.js file and I know that these...

How do you get a list of commands available on a gem?

I just installed a gem but when I type gem_name --help It says: 'gem_name' is not recognized as an internal or external command However, when I type gem list --local the gem shows up in the list so I know it's there - I just don't know how to see what it does. Is there a different instruction to use to find out what commands ...

Ruby on Rails - is seeding data with fixtures dangerous?

I have fixtures with initial data that needs to reside in my database (countries, regions, carriers, etc.). I have a task rake db:seed that will seed a database. namespace :db do desc "Load seed fixtures (from db/fixtures) into the current environment's database." task :seed => :environment do require 'active_record/fixtures' ...

Rails has_and_belongs_to_many is confusing me with fixtures and factories

General Confusion I have bands which can have 3 genres. I read in a previous SO post that the proper way to handle this is a couple steps: 1) In band.rb has_and_belongs_to_many :genres 2) Create a band_genres join table Even after reading the documentation, I am a bit confused as to what HABTM actually means. I guess I would just n...

How to remove "X-Runtime" header from Nginx/Passenger?

EDIT -- the solution I posted below probably applies to any server (Nginx/Apache/anything else), because this header is set in Rails itself. Anyone know where the "X-Runtime" header can be removed in Nginx & Passenger? I've grepped the source files and haven't found anything yet, but I'd like to get rid of it for security since it's ...

file_field_tag : what was the original file name?

My site allows users to upload csv files for processing. It all works fine, but on the response I'd like to report something like "Your file abc.csv processed OK". Unfortunately I cannot seem to find the actual original file name in the params, even though Firebug tells me it's part of the post. Any tips? Thanks.... ...

Current ver of Passenger with Rails 1.2.6 app?

Hi, Due to a number of issues, my app is currently stuck in Rails 1.2.6-land. Converting it to Rails 2.3 is planned, but will be awhile. Question: Does current Passenger support Rails 1.2.6? I've heard different things. I'm currently using nginx and mongrels but 'dem dogs are getting tired. Thanks! Larry ...

Ruby on Rails field average?

Is there an easy way to obtain the average of an attribute in a collection? For instance, each user has a score. Given a collection of user(s) (@users), how can you get the average score for the group? Is there anything like @users.average(:score)? I think I came across something like this for database fields, but I need it to work f...

Rails SQL Query with find

I want this SQL query to be written in rails controller using find select id,name from questions where id not in (select question_id from levels_questions where level_id=15) How will I do this?I am using Rails framework and MySQL db thanks in advance. ...

Rails select_tag with ajax action

I have the following select list. <%= select_tag(:editlevel,options_from_collection_for_select(Level.all, :id, :name)) %> when the user selects an option from the above list, the list below should be populated with values from database based on the above selection. <%= select_tag(:lques,{},{ :size =>10, :style => "width:200px"}) %> i...

Rails does not recognize sqlite3 REAL datatype

I have created the following table in sqlite3: CREATE TABLE Test ( Id TEXT PRIMARY KEY NOT NULL, Count REAL ); But when I try to generate a model for this table, the schema.rb gives the following error: Could not dump table "Test" because of following StandardError: Unknown type 'REAL' for column 'Count' Is the...

redirect_to using POST in rails

Is it possible to redirect using a POST method ? Or should redirects always be made using GET ? The use for this is in the final steps of an order process for an e-commerce site, to send the data to the payment processor, without introducing an extra step for the user. ...

How to find unrated models with acts_as_rateable

I have a rails application using the acts_as_rateable plugin. I'm stuck on figuring out how to retrieve unrated models using this plugin - however this is more of a general rails/SQL question than specific to this plugin. Acts as rateable adds the following to the schema: create_table "ratings", :force => true do |t| t.integer "r...

Error running rake task from IDE

I am having a problem running the 'test' Rake task from IntelliJ Idea in Ruby On Rails application: *Error running test: File 'test/unit/autorunner.rb' wasnt found in $LOAD_PATH of Ruby SDK with interpreter: '{1}'* But the file is located at %RUBY_HOME%/lib/ruby/1.8/test/unit and I have no problems when running other rake tasks. Plea...

Does a framework like Factory Girl exist for Java?

Factory Girl is a handy framework in rails for easily creating instances of models for testing. From the Factory Girl home page: factory_girl allows you to quickly define prototypes for each of your models and ask for instances with properties that are important to the test at hand. An example (also from the home page): Factory....