ruby-on-rails

To gem or not, that is the question

Hello! I'm building a simple CMS on Rails and I'm thinking about how I can package it so that I can easily reuse it in other projects and eventually share it as open source. This leaves me wondering if it's possible to package it as a gem, with views, controllers, models, images, stylesheets, etc, and later just include it in a new sit...

rake db:migrate produces "rake aborted! could not find table" error

I'm new to Rails and I'm building a simple project-tracking app for my employer. I've been developing the app on my Mac and pushing it to github. I just managed to clone my github repo to a windows box behind my company's firewall in hopes of letting colleagues try the app out. But when I go to rake db:migrate to initialize the database...

Creating thumbnails for bmp and tiff files through Rmagic

Hi, I install plugin attachment_fu for uploading an images in rails. It's working properly but the thumbnail for .bmp and .tiff images is not created through RMagic processor. What can I do for creating thubnail for .bmp and .tiff image format. Please give the solution over it. Thanks. ...

Is there any method available to find changed attributes for objects?

I want to fetch only changed attributes of an object. Is there any method available which returns all the updated attributes? ...

How to create an EngineYard-like service for other languages?

Hi, Does anyone know what is needed to create an EngineYard-like service for other languages? Where should one start? Thanks ...

Rails 3 acts_as_commentable Error: undefined local variable or method `acts_as_commentable'

Hello, I'm building a Rails 3 app and am trying to install acts_as_commentable Here's what I did: Added to my Gemfile: gem "acts_as_commentable" Ran bundle install Generated a Migration with the comments.rb (Comments table was created correctly) I then wanted to enable my book controller for commenting, so I added to books_controll...

Testing a ApplicationController before_filter in Rails

I have an application that detects the subdomain on a request and sets the result to a variable. e.g. before_filter :get_trust_from_subdomain def get_trust_from_subdomain @selected_trust = "test" end How can I test this with Test::Unit / Shoulda? I don't see a way of getting into ApplicationController and seeing what's set... ...

Rails: Preserving GET query string parameters in link_to

I have a typical search facility in my app which returns a list of results that can be paginated, sorted, viewed with a different records_per_page value, etc. Each of these options is controlled by parameters in the query string. A simplified example: /search?q=test&page=2 Now say I need to display a set of links that set records_per...

Rails: Returning a blank select option with observe_field?

I have an observe_field call in my app like this: = observe_field "marketSelect", :update => "merchantSelect", :with => "id", :url => { :controller => "markets", :action => "get_merchants" } That code activates the following action in my markets controller: @merchants = @market.merchants.sort_by { |merchants| merchants.name } Tha...

jQuery function to load Rails partial?

I have a jQuery function that updates my data ever few seconds. But! It's not parsing the javascript it's loading. It just calls it appropriately every few seconds, and replaces my content with unparsed javascript code. setupMediaIndexPoller: function(organization) { url = '/organizations/' + organization + '/media/photos_and_video...

accepts_nested_attributes_for through join table with attributes on the join

How can I use ActiveRecord's accepts_nested_attributes_for helper in a has_many :through association while adding attributes to the join table? For example, say I've got a Team model: class Team < ActiveRecord::Base role = Role.find_by_name('player') has_many :players, :through => :interactions, :source...

button_to :action => 'destroy' looks for 'show'

This seems incredibly similar to a question I had answered just a few days ago, but the solution then isn't working now. I'm building a rails app, and I am trying to have a button_to trigger a destroy in a different controller. the code I have for the button is <%= button_to "delete", :controller => :meals, ...

Problem with ActiveRecord::Dirty with RubyAmf.

I am using changed?,changes methods on console and that's working fine ... But inside my model it's not returning expected result .. I am using flex as my front end .. Any idea about it ?? RubyAmf causing problem ?? ...

How do I package a rails as a standalone executable.

I've been developing a web application and a lot of customers are asking if they can host the application in their network (for security reasons). I have been looking for a way to package up a rails app into a single executable (with server and all), but haven't been able to find anything. My other requirement is that we distribute it ...

Ruby on Rails 3 link_to - Why do I get different html links?

<%= link_to 'Testing', wak_path %> *This requires a routes: match 'wak', :to => 'home#wak' Did they take this out of rails 3.0 or what is going on? <%= link_to 'Testing, :controller=>:home,:actions=>:wak %> But in the views, I'm getting two different code, the top method works, though the second method dosen't have the same behavi...

Ruby on Rails Session Question

Rails 3.0 After doing rake db:sessions:create then adding the line of code in the session_store.rb, CouponManager::Application.config.session_store :active_record_store What else needs to be done before I'm capable of using sessions like session[:ttl_qty] = 5 ...

Ruby on Rails ERB Question

I have a question with turning this html into erb. <button name="support" type="button" value="Get Support" class="brightOrange"> <span>Get Support</span> </button> I've been trying to do something like this in rails. <% form_tag get_support_path do %> <%= text_field_tag :email, "Email:" %> <% submit_tag "Join", :class=>"bri...

Ajax on Rails - I'm having an issue...

I'm working on a Ruby on Rails web app, in which I've got several lists of posts. Each post will use Ajax to load their comments. In order of populating them in the right place, I'm doing the following: Each post has a div with an id formatted as follows: <div id="my_div_<%= post.id %>"></div>. So, for example if the post.id is 12, the ...

Rails Mailer: sending emails to a local file

Is there any way to send emails in rails 3 to a local file or so, instead of using an SMTP server? I'd like to test the email's contents without using any kind of SMTP, ideally only in DEV environment. The best would be a local SMTP or something that allowed me to inspect emails, check email addresses, etc. ...

Comparing two similar hashes in ruby

I'm using ruby 1.8.7 and I need to compare two hashes that I have, which are essentially the attributes of a model. Hash A is smaller than Hash B, and Hash B has all of the attributes of hash A, plus some extra attributes I don't care about. My overarching goal is to see if the elements of A are the same as the respective elements of B...