ruby-on-rails

Store image in database using rails paperclip plugin

I have an application that uses the Paperclip plugin for image upload. Now that app should get deployed to an host(heroku) which has a read-only file system. Can I somehow tell paperclip to store the images in the database? ...

How to obtain current action from within model in RoR?

I found some information to get action_name within the controller, but I need to know what it is inside my model. I'm kind of second guessing myself and wondering if that's at all something you would need or could get from being within the model, but I'm not sure. Please let me know if there's a way to get something like action_name with...

Which Rails content management systems (CMS) work with ActionMailer?

I want to use my Rails app to send campaign-style emails ("Hi, call your representative! Her name and number are...") that are customized on a per-user basis. Effectively, each user could be seeing a slightly different email. Some of these emails would need to contain link_to's, and other helper functions. I've never used any CMS in Rai...

Anyone have a full ActsAsWizard example?

I was trying to us the acts as wizard plugin and feel like I'm missing a step between what's in the readme and getting the code to actually run. For instance there's nothing about how to setup the routes, what validations are performed between states, if the form is submitted at each step. If anyone has used this plugin, can you please ...

How to write "<%" in a erb file

I have an .erb file where I'd like to return the following text: Name <%r> When I render this file, the erb interprets the <% as a ruby code and doesn't render the % signal. I found one way to do this, putting the % signal in a String like this: Name <<%= "%" %>r> But this is very ugly. Is there any other way to do it? ...

How do you prevent database changes inside a Rails ActiveRecord before_create filter from getting rolled back when it returns false?

I've added a before_create filter to one of my Rails ActiveRecord models and inside that filter I'm doing some database updates. Sometimes I return false from the filter to prevent the creation of the target model, but that is causing all the other database changes I made (while inside the filter) to get rolled back. How can I preven...

ActiveRecord named_scope, .scopes

The background to this problem is quite complex and convoluted, and as I am looking for a simple answer, I will leave it by the wayside in explaining my problem, and instead provide this hypothetical situation. If I have a simple ActiveRecord model called Automobile, with named_scopes like below: named_scope :classic, :conditions => { ...

Rails migration file not adding all my defined columns to the db

Hi, I'm trying to create a rails app, but somethings going wrong, I'm getting a nasty error undefined method title' for #` I've used this ling: ruby script/generate scaffold Blog title:String body:text to generate the following migration file: class CreateBlogs < ActiveRecord::Migration def self.up create_table :blogs do |t| ...

How to use "Object" as model name in ROR ?

I love those simple words such as "Object", "Property", "Value" and would like to use them as Class Names, but seems they are reserved. ( ? ) ROR failed on many things with a model named "Object" Make a prefix doesn't look good, such as CCObject, CCProperty. Is there a way to allow me to use those simple words directly? What I want...

delicious clone

I'm looking for an Open Source delicious clone written in ruby on rails, is there such a thing? ...

link_to() in Rails flash

When a user fails login on my Rails app, I'd like to point them to a password reset page: flash[:notice] = "Login failed. If you have forgotten your password, you can #{link_to('reset it', reset_path)}" However, I can't use link_to in a controller. What's the best way to do this without mixing controller and view logic? My best gue...

Specifying Inheritance Class Type In Rails Form

I have a parent class called Vehicle, and a couple of children classes: Car, Truck, SUV. Im using Single table inheritance and id like in the form to be able to select the TYPE (Car, Truck, SUV), each with a couple of associated fields, and then have rails build the associated type. This sitation is made more complex b/c Vehicles belongs...

Rails Idiom for Post-Update Notification

All/Anyone, Curious what the prevalent Rails idiom is for indicating the success/failure of a particular action to the end user? For example, let's say you have a restful User resource and update is invoked on said User resource; once the update has completed and I've routed the user back to edit.html.erb - I'd like to indicate whethe...

Silly rails question: undefined method within class declaration.

Hi all- I have a user class, where I am trying to attach a profile created by a factory. Here is the class: class User < ActiveRecord::Base acts_as_authentic has_one :profile after_create {self.profile = ProfileFactory.create_profile(self.role)} end and the factory looks like this class ProfileFactory def self.create_pr...

Logging inside threads in a Rails application

I've got a Rails application in which a small number of actions require significant computation time. Rather than going through the complexity of managing these actions as background tasks, I've found that I can split the processing into multiple threads and by using JRuby with a multicore sever, I can ensure that all threads complete in...

How should I architect this with Ruby on Rails?

Sorry for the vague title, but this is kind of hard to put into one line. I have a database full of contact information, and I want to be able to put those different contacts into groups which will also be stored in the database. So, maybe I have 2 groups, "coworkers" and "neighbors", I want to be able to see a list of all my contacts...

How to implement Active Record inheritance in Ruby on Rails?

How to implement inheritance with active records? For example, I want a class Animal, class Dog, and class Cat. How would the model and the database table mapping be? ...

Posting a form through popup in Rails

I have a model called Details, and two controller methods new and create. New method displays a form to create Details (in new.html.erb), which gets posted to the Create method that saves it. (when it succesffully saves, it it renders the new.html.erb file with the details.) This works as expected. Now i want a separate page with a link...

Has anyone created a Rails app with support for Jquery-ui & Themes

Has anyone gotten a Rails application playing well with JQuery UI and Themes I would like to build a generic application which includes common basic layouts, styles, authentication and various other optional tools. The idea is to build this basic application using a rake and setup yml files. Once run, I would like to be able to "skin...

FixtureReplacement with Cucumber

Hi, I am using Cucumber with Selenium, FixtureReplacement and DatabaseCleaner. Funnily enough, my data I created with FixtureReplacement is not accessible from my tests. I have added an own rails environment for selenium and I am using an own profile for my enhanced selenium features. My cucumber setup for the selenium profile is: We...