ruby-on-rails

splash (landing) page for rails app

I am creating a splash page for a rails app which contains an email field for the user to fill up and get notified when the site is completely launched. What is the best way to go with? Should I create a new application just for landing page OR should I use the same app with some variable set like ":splash => true" which would give ac...

Ruby on Rails: what's the minimum I need to load if I want to use ActiveRecord in a maintenance script

I created a top level directory called 'maintenance' in my Ruby on Rails application. There's mostly scripts there that I use for my own cleanup/project maintenance. I want to be able to load my models and activerecord so I can query them in my script. What do I have to load at the beginning of the script to get it to properly know my en...

get current variable Rails, in before_save

Is there a way to get the current variable? lets say that i have a "title" attribute in a method and i want to check in with the old value of the variable ? how could i accomplish this ? ...

Ruby on rails: printing the variable name for debugging purposes in the console.

Lets say I have i variable var witch is a pointer to another variable named user_id. How do I puts var such that I can see in the console user_id = (whatever the value is) Reason why I want to do this, is because I want to write a method called print_debug_block, where you give it an array of variables, and it prints in the following f...

Rails: using jquery + facebooker to generate fb:dialogs

I have a list of Area objects that I'm displaying in a Facebook application. I would like to have a link for editing them, next to each row. I would like the form to appear in a <fb:dialog>, so I created the following partials: # _edit.fbml.erb <% fb_dialog("edit_area_#{@area.id}", false) do %> <%= fb_dialog_title "Edit area" %> <% fb...

Can you use Ruby to develop a touchscreen supported application?

What api's do you use to develop a touchscreen point of system in Ruby? ...

How to disable logout on timeout with Authlogic?

Hi, I'm running a Rails web app where the authentication system is based on Authlogic and tardate's authlogic_rpx. The first one handles everything about sessions, the second one does the mapping with RPX/Janrain (which offers the users to sign in with Twitter or Facebook). All the users are always automatically logged out after a cer...

Weird SearchLogic error (Rails)

My search form is triggering this. undefined method `id_like_before_type_cast' for #<Class:0xb5ffff68> Here's the line from the form: <%= f.text_field :id_like %> ...

Ruby on Rails: alias_method_chain, what exactly does it do?

I've tried reading through various blog posts that attempt to explain alias_method_chain and the reasons to use it and not use it. In particular, I took heed to: http://weblog.rubyonrails.org/2006/4/26/new-in-rails-module-alias_method_chain and http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/ I still do not see any prac...

Vestal Versions -

Hi, I'm using the Vestal Version Fork here for Rails 3 support: http://github.com/adamcooper/vestal_versions/ The issue I'm having is that the updated_by => current_user is not storing in the versions table on update. def update @book = Book.find(params[:id]) respond_to do |format| if @book.update_attributes(params[:...

Rails Single Table Inheritance using Foreign Key (ID)

Hi, I have to model an association structure and the association is divided into divisions/subdivisions/sections etc. So I've created a simple Entity-Attribute Model: I'd like to use rail's single-table-inheritance but it seems like this works only if the type column is a string. My question is how to achieve this with my approach? S...

Rails: Cucumber forgetting CanCan Authorisations

Hi folks, I'm trying to write up some cucumber tests to ensure cancan permissions are set correctly, and I'm having an odd problem: When I log in through the following code, capybara says I've logged in as expected. However, when I then go to a resource which requires the given login, I get CanCan's "not authorized" message. Capybara p...

Something wrong in my sequence of factory creation..

I was hoping someone would spot why this wouldn't work. I am getting an error thats being called because the attributes I specify with Factory_Girl are not being applied to the stub before validation. The Error: undefined method `downcase' for #<Category:0x1056f2f60> RSpec2 it "should vote up" do @mock_vote = Factory.create(:vote...

Creating a different "genre" of my website (i.e., I have a stackoverflow-equivalent and I want to create a serverfault-equivalent)

My site, Rap Genius, explains rap lyrics. I want to create a new site, Rock Genius, that explains rock lyrics – otherwise it'll be the same (same layout, same DB schema; like Serverfault is to Stackoverflow) What's the best way to do this? Approach 1: Fork the code Fork the Rap Genius code, change the relevant parts (e.g., "Rap" -> "R...

Stopping unfinished Ajax requests using jQuery

Hi, I'm implementing a live search feature on my website(rails). Everytime there is a keypress, I'm submitting the form. But if the user types several characters, several search requests are sent to the server. I was wondering if there is a way to stop the previous(unprocessed) requests. I want only the last request to be successfully p...

Need help in Timezone in Rails ActiveRecord

Hi, I am faced with a peculiar issue with respect to Timezone in Ruby. I want to convert the following Sat Sep 11 15:15:00 +0530 2010 to Sat Sep 11 15:15:00 -0400 2010 As you can notice, only the time zone has been converted and no other part has changed. How to do this in Ruby. ...

Can you put a variable in a regexp?

I'm trying to validate wether a Model.category equals any existing Category name unless Category.exists?(:name => self.category.downcase) I had to put downcase in this to ensure all of them were downcased so they could match up as strings. But its a big server hit to update the attribute before_save, and I was thinking of just matchin...

How does your rails app include javascript?

Hello all, I'm very curious how your Rails apps include javascript. For example: do you package all your js code into a single file and serve it for all requests? do you conditionally load certain js depending on controller/action? what tools or techniques do you use, ie: asset_packager, yui compressor, sprockets, BigPipe inspired imp...

SQLException after an Array.exists?(object) with Rails

Hi, I have this strange SQL error when I try to know wether an object is in an array: @announcement = Announcement.first puts "YAY" if current_user.announcements_read.include?(@announcement) Error: ActiveRecord::StatementInvalid (SQLite3::SQLException: ambiguous column name: created_at: SELECT "announcements".id FROM "announcemen...

How do I test for belongs_to and has_many in Rails?

I'm using rspec and I'm trying to test whether or not my model y has many x. I've tried all sorts of things, including looping through the methods array, and can't seem to find a good method online. So what should I use? ...