ruby-on-rails

Why am I getting a file exists -c: error

I am trying to use paperclip to upload a csv file to my rails application so I can parse it into the database, but whenever I select the file and try to upload it, the controller returns the error File exists - c: when it tries to save the instance. When I inspect the object in debugger mode I get this: #<Import id: nil, datatype: "use...

rails and mailchimp

What is the preferred gem or plugin when connecting to the mailchimp api via rails? There's a list here, but I have yet to try any: mailchimp ruby Any feedback is appreciated! Thanks! ...

Rails -- How to setup model that can belong to either of 3 different models

I'm trying to make an app that does testing similiar to what you would experience in school. I have a model Question, which can belong to either an Exam, Quiz, or Assignment. Should I create fields for ":exam_id, :integer, :null => false; :quiz_id, :integer, :null => false; :assignment_id, :integer, :null => false;"? The question w...

Mass downloading from Rails (maybe with Paperclip)

I need to allow multiple downloading of small documents in Rails, preferably using Paperclip (I've already used it to enable uploading). Specific needs: Zip the files for download. Download different file types together (.jpeg, .doc, docx, .pdf). I have found lots of tutorials online for multiple uploading, but not for downloads. I...

How do I create a RedCloth live preview using jQuery?

I've had problems with many of the WYSIWYG gems/plugins for Rails, so I'm building one myself using the RedCloth gem. I want users to see a live preview of their HTML-formatted text as they're filling out a form, but don't know how to do that using jQuery and RedCloth. Here's what I tried in application.js: $('#comment').keyup(function(...

Error installing taps

Here is my Gem Environment: RubyGems Environment: - RUBYGEMS VERSION: 1.3.5 - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] - INSTALLATION DIRECTORY: /var/lib/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM...

remove_column not removing column or giving any errors in rails

I have a sqlite3 db in a rails app with the following schema ActiveRecord::Schema.define(:version => 20100816231714) do create_table "comments", :force => true do |t| t.string "commenter" t.text "body" t.integer "post_id" t.datetime "created_at" t.datetime "updated_at" end create_table "posts", :force ...

What's the fastest Ruby on Rails setup for Windows 7?

I have InstantRails installed along with WeBrick and sqlite3. What exactly do I type in the Windows cmd console to setup a db called 'development' and to get the entire things running? This is my #&%^# 4th day of installation. I can get everything running on my localhost EXCEPT setup my db. I'm not a programmer so if you have a good ur...

mysql.sock stopped working on rails3RC ruby 1.9.2

Rails 3.0.0.rc ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.4.0] Today I upgraded to rails 3.0.0RC (from beta4) and ruby 1.9.2 (via RVM). Now when I do rake db:create in a new test app I get the below error. Anyone know what I'm doing wrong? I did 'bundle install' with no errors. DEPRECATION WARNING: Calling a method in ...

trigging after_save on an embedded item when assigning it via '<<' in mongoid?

I was wondering if there was a way to trigger the after_save callback on an embedded_in object in Mongoid mapper. Example: i = Image.new(:file => file) user.images << i # => i.after_save should be triggered here I'm aware that if I call i.save after words, it will fire, however really hard to remember to do that throughout my code. ...

Extract bundled gems into system gems

This might sound as a strange thing to do. Is there a bundler way to extract the bundled gems (from a Gemfile or from .bundle) and install them as system gems outside of the bundler context? Something like bundle package, but instead of caching them in vendor/cache, installs them as system gems. ...

Paperclip with albums

I'm struggling with paperclip and adding the attached images to albums. Should I be writing an album_id to the images row in the database? Right now, I'm trying to use an album model, which belongs_to :user and has_many :photos. The photo model belongs_to :album and has_attached_file. Is that the way to go about it? I'm really new to Ra...

starting ruby on rails application

Hello, I'm having problems starting my application. Basically, I have an existing application, but just recently trying to test out ruby on another machine. As such, I keep getting the welcome screen, even though I'm starting script/server in my application folder. Any help to actually start my application would be much appreciated....

Ruby on Rails: Building a child with default values when its parent is created.

I have a parent and child model relationship. In the child's migration.rb, the child model's columns each have default values (except the parent_id column). When I make a new parent object, how can I make it so that a child object is created and saved into its table with the data from the default values along with the parent_id? I'm th...

How can I get a unique :group of a virtual attribute in rails?

I have several similar models ContactEmail, ContactLetter, etcetera. Each one belongs_to a Contact Each contact belongs_to a Company So, what I did was create a virtual attribute for ContactEmail: def company_name contact = Contact.find_by_id(self.contact_id) return contact.company_name end Question: How can I get an...

What happens when you run class_eval on something that's not a class?

test = "a" test.class_eval do # what is going on here??? end ...

Trouble saving serialized form data in Rails

I have a Campaign model which I want the user to be able to check off and on a checkbox for each state, which I want to store in an array in one the fields, like ["CA", "NY", "OH", "FL"]. I'm not sure if serialized is the correct terminology here. I have some form fields generated like so: <% State::NAMES.each do |state| %> <%= check...

Getting delayed job to log

#Here is how I have delayed job set up. Delayed::Worker.backend = :active_record #Delayed::Worker.logger = Rails.logger Delayed::Worker.logger = ActiveSupport::BufferedLogger.new("log/ ##{Rails.env}_delayed_jobs.log", Rails.logger.level) Delayed::Worker.logger.auto_flushing = 1 class Delayed::Job def logger Delayed::Worker.l...

Rspec problem with authentication and before_filter

Hi guys this one is puzzling me xD I'm sure its something small that my logic just doesnt compute... I got the following test in my controller spec: describe "delete 'destroy'" do before(:each) do @post1 = @user.posts.create(:wall_id => @user2, :body => "foobar") @post2 = @user.posts.create(:wall_id => @user, :bod...

Should a Rails app have to work in jRuby, when I want to deploy it via warble on a Java application Server?

I want to make sure, the app will work properly before I "warble" it. Does it have to work in jRuby for that or does it work anyway? ...