ruby-on-rails

Issues upgrading bundler to 0.9.4 with Rails 2.3.5

Hi guys, Heroku made all its apps upgrade to the latest version of bundler (0.9.4). I followed all the instructions found on the README (including the upgrading instructions). But once I upgrade my application no longer runs. For example i get NoMethodError (undefined method `acts_as_taggable_on' for #<Class:0x1b7f614>): My Gemfi...

Rollback active record state: wrong number of arguments (1 for 0)

ArgumentError in SourceController#update_source wrong number of arguments (1 for 0) I try saving a new Article object into the database by writing: @article = Article.new(:title => new_a.title, :description => new_a.description, :source_id => self.id, :url => new_a.link, :pub_da...

Rails: 'if running locally' conditional javascript tag include

I want to load jQuery from http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js regularly, in production/development environment, as long as I'm not running locally, but my own local jquery.min.js if running locally (e.g. 0.0.0.0:3000) Reason why is that I have to do some development without internet connection sometimes, mo...

Rerendering partial view at a JavaScript event in Ruby on Rails

I would like to rerender some partial views in Ruby on Rails at a specific JavaScript event. Do you guys know how I could do that? More specifically, i have some custom in-place-editor fields (from my own helper based on scriptaculous), and I would like to update some partials whenever new values are submitted on the fields. I do have a...

Ruby On Rails Scaffold LoadError

I am learning Ruby on Rails using a book I picked up called "Head First Rails" I am in the first chapter and it tells me to create my CRUD procedures using the following command: ruby script/generate scaffold ticket name:string seat_id_seq:string address:text price_paid:decimal email_address:string the error I am getting is: ruby: N...

How to keep strings in yaml from getting converted to times

I have a yaml file which contains some times: hours: - 00:00:00 - 00:30:00 - 01:00:00 But as soon as I read them they get converted to time (in seconds), but I want them to remain as strings for a moment so i can do the conversion. Here's how I'm reading them: def daily_hours DefaultsConfig.hours.collect {|hour| ...

Filling a select with a series of times in increments, plus additional options

Using Ruby on Rails, I'm filling a 'select' with times using a given increment, such as every 30 minutes. Currently I'm writing out all the possibilities in a YAML file, but i feel like there's a slicker way. I'm thinking I want to provide a start_time, an end_time, an increment, and currently just one more option called 'Closed' (think...

Can't initialize local server for my Rails apps

Hi all, My rails apps have been freaking out on me lately. I start my local server by running "ruby script/server" like normal. The server starts, but when I try to access it via "http://localhost:3000/", it throws me a 500 error. This happens for all my rails apps, even the old ones I've left unchanged for several months now. Here ...

Rails, upload progress bar

I've looked at a number of resource for creating an upload progress bar in Rails using Passenger. dromo's blog, swfupload, plus more. I haven't been able to get one working. Any Rails people actually have a working example of successfully implementing upload progress bar? ...

proper way to setup facebook canvas url and routes in a rails app

i have an existing rails application to which i am adding a new controller to handle requests from a small facebook app (using the facebooker plugin) i am building. in the facebook app's config i set the canvas callback url to http://my.host.ip/fb/ in a pure facebook application the url would leave off the /fb/ and the user would be d...

Trouble with Embedded Forms and Belongs_to in Rails

Stuck trying to figure out how this nested form should work. Right now, it's not displaying the embedded text_area (g.text_area), but I don't see why. Any help would be much apprecaited! class Channel < ActiveRecord::Base belongs_to :first, :class_name => "Message", :foreign_key => 'first_id' accepts_nested_attributes_for :first...

Show data from a hash-table into a select box

Hello, A have a hash-table with countries in it like this: @countries = {'United States' => 'US', 'France' => 'FR'} and I use the following code to display it in a select box: <%= select_tag 'countries', options_for_select(@countries.to_a) %> Now when it saves data in my table I got in my row US, UK...and so on, now ...

Duplicate Entry errors using Shoulda Macros

I wrote some tests for a several models and controllers of a Rails application using Shoulda macros, but one after another they each fail with the error ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '1' for key 1: INSERT INTO `replies` (`created_at`, `from_user`, `updated_at`, `read`, `text`, `tweeted_at`, `id`, `user_id...

Find average date from collection of dates (Ruby)

Hey guys, I have a table of guesses, within each guess is just a date. I was wondering how I would go about turning two or more dates into an average. <div id="logic"> <% foo = Date.today %> <% bar = Date.today + 10 %> <%= (foo + bar) / 2 %> Something like this, but obviously Ruby wont let me divide the two dates, any help much appr...

rails / erb bug or feature

just transfered an old rails application (1.1.6) to a new host providing a passenger/enterprise ruby environment. one of the programmers used ruby tags to comment html content and this seems to cause some trouble on the new host. an example: <div> <% collection.do_domething %> ... <% end %> <% # finished showing content %> </div> <div>...

ActiveRecord select attributes without AR objects

I have a table with MANY rows, I need just the IDs of certain rows. The slow way is to call SomeARClass.find(:all, :conditions => {:foo => true}, :select => :id) This returns AR Objects... Is there a way to call a select on a class and have it return a plain old ruby data structure. Something like this: SomeARClass.select(:id, :con...

How prevent a user log in twice with the same username - using Rails Authlogic?

Hi, my question is as in the title. Thanks, Michal. ...

paperclip polymorphic association and saving

I changed my photo.rb model to be polymorphic and be usable to all sorts of other models needing to save images and it works fine except I can't figure out how to save new attachments properly through the parent model. Any ideas? Do I have to approach this differently somehow? As, its also not getting the imageable_type...which i'll h...

Rails: request.xml?

Hey, I would like to check whether the request is XML od HTML. When HTML the page is redirected to login form (if a user is not logged in) and when XML the user get not authorized status code. Example: class ApplicationController < ActionController::Base def require_user unless current_user IF XML RESPOND WITH CODE...

Sass Compass multiple themes ruby on rails

hi all I have a rails app that is a sort of CMS and i alow users to create their own version of the applicaton on a sub domain. I also want to let them style their app version the way they want but changing a few fields or small config file. I was hoping to be able to use sass and compass and be able to let users change varialbes for ...