ruby-on-rails

using UUID as primary key in rails and polymorph relationships

I'm creating a rails 3 application that will be decentralized and I need to use UUID as primary key for my tables, what would be the best gem, plugin for the Job. I also would like to know if it is possible to make in ActiveRecord polymorphic relationships without using the polymorphicable_type column for it, given the case that I'm usin...

Rails: simple bundler question with ruby-openid

Hi! I just installed the ruby-openid gem and then bundled it by entering gem 'ruby-openid', :require => 'openid' in the gemfile. Then I started bundle install and bundle lock. Everything worked fine so far. But how can I now access the classes of ruby-openid. OpenID::method won't work for me. It raises a not found error. What ha...

How to deal with hidden field with cucumber and webrat ?

I have to set a select date field with the month and day discarded. So Month and day are hidden in the form which caused a "undefined method `options' for # (NoMethodError)" when executing the cucumber scenario. How can i solve this issue and get the year correctly into the cucumber step ? ...

File storage backend for Rails

Hello, I have a Rails application that I want to add file upload to, so that the users have access to a "resources" section where they can upload and share (although not publicly) any type of file. I know I could build a solution using paperclip and S3 for example, but to try and avoid the admin overhead of all that I'm looking at API i...

Noob Rails ? about learning Rails

Hi All I have been programming for a while and for the past 3 or 4 months have been learning ruby. I am not an expert by any means but I believe I have the basics down. I decided to start learning RoR and bought the "Agile Web Development with Rails 3rd Edition" and have been dutifully going through the chapters one by one. Currently...

Does a rollback still occur if I use begin...rescue and an error occurs?

I've got some strange errors happening in my rails app and I'm trying to log better errors instead of the whole stack of passenger stuff that I don't care about. I thought I would do this with a Rescue clause and explicit error handling, like logging the params hash. But I'm concerned if this would interrupt any rollback that is happenin...

Sending emails based on intervals using Ruby on Rails

Hi, I would like to be able to send a string of emails at a determined interval to different recipients. I assign to each Contact this series of Emails called a Campaign, where Campaign has Email1, Email2, etc. Each Contact has a Contact.start_date. Each Email has email.days which stores the number of days since a Contact's start-date...

Is it possible to implement has_many, :through with ActiveScaffold?

Consider the following models: class Artist < ActiveRecord::Base has_many :artist_events has_many :events, :through => :artist_events end class Event < ActiveRecord::Base has_many :artist_events has_many :artists, :through => :artist_events, :order => 'artist_events.position' end class ArtistEvent < ActiveRecord::Base defaul...

Rails: How can I define one-to-many relationships using the rails "generate" script?

I'd like to run the rails "generate" script and create a model that belongs two other models. Is there a way that I can do this? ...

problem with uninitialized constant

Hi, I have the following controller class ActiveUsersController < ApplicationController def edit end end And my routes.rb is like this: map.resources :active_users When I try to access the controller using the url http://localhost:3000/active_users/COo8e45RqQAHr6CqSCoI/edit I got the following error: NameError in Active usersCon...

Issues finding gems installed in my home directory during runtime

I'm on a shared host (yes, non ideal...but cheap!) and setting up gems for my rails app, and can't figure out why the gems are unavailable from ruby scripts (probably doing something stupid!) Env. variables: GEM_PATH = /home/myhome/ruby/gems:/usr/local/lib/ruby/gems/1.9.1/ GEM_HOME = /home/myhome/ruby/gems PATH = /usr/local/bin:/bin:/us...

remote_function keeps adding authenticity token on GET requests

Hi, I got the problem similar to this post here: https://rails.lighthouseapp.com/projects/8994/tickets/106-authenticity_token-appears-in-urls-after-ajax-get-request routes.rb map.namespace(:admin, :active_scaffold => true) do |admin| admin.resources :regions, :shallow => true do |region| region.resources :birds, :collect...

Ruby: How do I define a datetime field in YAML?

I'm creating test data for a Rails app. How do I define the value for a datetime field in YAML? ...

How to install gem pg on snow leopard

I need to install gem pg on snow leopard because I am running rake on rails codebase. I am not using postgres. This is the error I am getting. $ sudo gem install pg Password: Sorry, try again. Password: Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. ...

how do I get only the stack trace from my app in rails?

The default behavior seems to be printing large stack traces like ArgumentError (too few arguments): app/controllers/players_controller.rb:55:in `format' app/controllers/players_controller.rb:55:in `create' /dh/passenger/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request' /dh/passenger/lib/phusion_passenger/abstract_re...

RAILS plugin delegate_belongs_to

Hi there, anyone could give reference and sample about this plugin delegate_belongs_to in rails? Thanks ...

Rails: errors in production vs development

In Rails, is there a way to display different error messages on a production rails server (a nice graphic) vs a development server (detailed error information, stack trace, etc.)? ...

RoR - Paperclip - How to set minimal width of an attachement

Hi, my layout's requirement is to keep all thumbnails at 80px height, not higher, not smaller. In my model I set the style to :thumb=> "500x80>", so basically almost every picture which is not too wide gets its perfect miniature with 80px height. Sometimes, however, my pictures are narrow and high, so the thumb can have unclickable dimen...

rails, rest, render different action with responds to

Maybe my logic is not restful or know if this is how you would do it but this is what I am trying to do. I'm getting a category inside a category controller and then once I get that category I want to return to an index page in a different controller but keep that @category and the Category.busineses. Before rest I would have just done...

validating creation by post_id and ip_address - Ruby on Rails

I have created a blog application using Ruby on Rails which includes the ability to vote on posts. A user can click vote and a record is created in the vote table. I am now trying to limit that same person from voting for a post multiple times. class Post has_many :votes end class Vote belongs_to :post end When a vote record is c...