ruby-on-rails

rails group by multiple columns

i have budgets table with emptype_id and calendar_id actual_head, estimated_head when i do Budgets.sum(:actual_head ,:group=>"emptype_id,calendar_id") i do not get the result grouped by the above two columns but only by the emptype_id however when i check the log the sql query is right "SELECT sum(budgets.actual_head) AS sum_ac...

Rails Routing - Not showing an action

I have two routes: map.all_devices '/all_devices', :controller => 'all_devices', :action => 'initialize_devices' map.show_user_date_select '/all_devices', :controller => 'all_devices', :action => 'show_user_date_select' I want a user to click on a button, do the show_user_date_select action then be redirect back to mysite.com/all_devi...

Where to put model "utility" functions in Ruby on Rails

I have a rails app with several models. I have a function that I want to access from several models. What's the best place to put this code and how can I make it accessible from the models that need to get at it? My understanding is that helpers are just for views. Is this correct? It seems wrong to create a plug-in and put it in th...

A copy of ApplicationController has been removed from the module tree but is still active!

Whenever two concurrent HTTP requests go to my Rails app, the second always returns the following error: A copy of ApplicationController has been removed from the module tree but is still active! From there it gives an unhelpful stack trace to the effect of "we went through the standard server stuff, ran your first before_filter on...

Rails partial table validations

I have a form that I'm trying to create which is broken up into sections. Each section saves a little bit of info to that table and then moves on to the next page. I'm trying to figure out the best way to validate the data for each section in the model. I was to use something like validates_presence_of, but that expects all of the data...

Git / Rails / Shared Hosting (Dreamhost) workflow

This is primarily a question about effective Git usage. I should first say I'm not an expert in Rails (at least in a production sense) and definitely a Git newbie, however, I have had some experience using SVN. My problem is that I am trying to create a rails application but do not know the best way to keep development local on my comp...

Pros/Cons of MySQL vs Postgresql for production Ruby on Rails environment?

I will soon be switching from sqlite3 to either postgres or mysql. What should I consider when making this decision? Is mysql more suited for Rails than postgres in some areas and/or vice versa? Or, as I somewhat suspect, does it not really matter either way? Another factor that might play into my decision is the availability of tools t...

Command to clear the cookie-based session store in Rails.

I often want to clear the session store in Rails, in particular, the default cookie-based session store. Some sites seem to suggest that rake tmp:sessions:clear accomplishes this task, but it appears that it does not. What is the proper way to clear the cookie-based session store? ...

Refreshing a DIV after form submission in ruby on rails

I have a controller and a view (no ActiveRecord for this one). The controller calculates the current time in several places in the world and the view presents them. I'd like to add a button that will make the clocks update. Adding a regular button which refreshes the whole page works fine, but I'd like to do that asynchronously using AJ...

has_many_polymorphs post install issue

hi all, immediately after has_many_polymorphs install with ruby script/plugin install git://github.com/fauna/has_many_polymorphs.git i start getting following error whenever i try to execute smth like script/generate or script/server => Rails 2.3.2 application starting on http://0.0.0.0:3000 /test/vendor/plugins/has_many_polymorphs/...

How can I render Ruby code in javascript?

I have a javascript part in my view, that I want to modify through locals I have defined in a helper. <script type="text/javascript"> var store = new Ext.data.JsonStore({ url: '/admin/administration/users/grid_data.json', root: 'users', fields: [ <%- for field in fields do -%> {name: '<%= field[:data_index] -%>'}, <%- end...

What Ruby on Rails plugin/gem would you recommend to implement widely-used blog publishing API (Atom, MetaWeblog, etc) in a custom blog

I have a custom-made blog running off RoR and I would like to implement publishing API. I would prefer to use a widely-used API - e.g. Atom, MetaWeblog, etc - so that I can post to my blog from almost any other web service - flickr, youtube, pixelpipe, etc. ...

rails - controller action name to string

hi, i have a rails question how do i get controller action name inside the controller action? f.ex. instead of def create logger.info("create") end to write something like def create logger.info(this_def_name) end what is a way to get this_def_name? ...

Importing CSV file into Rails sqlite3 database

Hi, I have created Rails database using the following schema: ActiveRecord::Schema.define(:version => 20090807141407) do create_table "trunks", :force => true do |t| t.integer "npa" t.integer "nxxFrom" t.integer "nxxTo" t.string "trnk" t.datetime "created_at" t.datetime "updated_at" end end In my CSV...

Looking for non-Rails content management system

I'm looking for a CMS writen in Ruby and not based on Ruby on Rails, are there some projects? ...

Error Deploying Rails Application

I had issues when I tried to deploy my Rails site when i start mongrel and start my app and rewrite and start with Apache the application has ben displayed but when i link to http://myapp.com/account/login Not Found The requested URL /account/login was not found on this server. Additionally, a 404 Not Found error was encountered wh...

rails - InvalidAuthenticityToken for json/xml requests

For some reason I'm getting an InvalidAuthenticityToken when making post requests to my application when using json or xml. My understanding is that rails should require an authenticity token only for html or js requests, and thus I shouldn't be encountering this error. The only solution I've found thus far is disabling protect_from_for...

What is an efficient way to render a large XML collection in ruby/rails?

I'm trying to render a large (ish) array of objects as a plist in Ruby on Rails. The collection currently contains up to 200 objects, each of which is essentially a record (dictionary of keys/values). The overall result format is a plist (as used by Apple) but logically it is not much different from any XML document. The problem I've hi...

ruby on rails int to minutes::seconds::milliseconds

I have this line, which shows the minutes and seconds. But I have to add milliseconds to it as well for greater accuracy. How do I add that in this line, or is there an easier way to get the desired result? @duration = [cd.ExactDuration/60000000, cd.ExactDuration/1000000 % 60].map{|t| t.to_s.rjust(2, '0') }.join(':')) The exact durati...

What does config.gem (in environment.rb) do?

I've been told that doing: config.gem 'tzinfo' doesn't obviate the need to require 'tzinfo'. Is this true of all gems? If yes, what exactly does adding config.gem WHATEVER do? ...