ruby-on-rails

Rails - Beginner wants feedback on how they've modeled their app and how to do it better.

I think the way I've modelled my app is a bit fishy and i need to rejig things, im just not sure how. I've already re-jigged and refactored before. It took a long time ( I'm a beginner ) and I'm hesitant to it again in case i head off in the wrong direction again. Basic Idea, user can submit an answer, another user can mark it correct o...

Plural to Singular conversion trouble in Rails Migrations?

Hi, I'm a beginner at Ruby On Rails and am trying to get a migration to work with the name Priorities So, here is the code I use in my migration: class Priorities < ActiveRecord::Migration def self.up create_table :priorities do |t| t.column :name, :string, :null => false, :limit => 32 end Priority.create :name => "...

Respond_to in rails

respond_to do |format| format.html format.xml { render :xml => @mah_blogz } end respond_to do |format| format.js end Whats this respond_to, format.html, format.xml and format.js. Whats the purpose, How they work. ...

Bizarre Bug with our Rails app in IE

We're experiencing a really bizarre bug in our Rails 2.3.4 app. This bug only happens in Internet Explorer (7 and 8). Here's what happens: A new customer creates an account at https://domain.com/signup/free (notice no subdomain) Their account is identified by a subdomain like "example.domain.com" After signing up, they get a welcome s...

Rails Model and DB schema with two foreign keys from the same table

I'm developing the Order Model for a Rails application.I'm trying to represent an Order which has BillToAddressId and ShipToAddressId as the foreign keys from the Address table. The address table is below : create_table :addresses do |t| t.string :country t.string :state t.string :city t.string :zipcode ...

How do I convert Windows 7 file-name encoding to UTF-8 for Ruby on Rails?

Hi (Ive looked at the other questions - none seemed to quite fit my problem.) I have some file-names under Windows 7 that need to be translated in to MySQL database (UTF-8) with Ruby on Rails. An example file-name includes "íéó" in some kind of Windows 7 file-system encoding. Ive tried many combinations of gsub and ActiveSupport::Mul...

SQL housekeeping tasks on Herkoku

Hi, I'm not sure how to do this... I have a database which contains a messages and categories tables. The categories table has a field which has a count of the number of messages related to it. Sometimes however I need to deactivate (active = 0) a message, at the moment this doesn't then update the category table... I will implement ...

Installing and using acts-as-taggable-on

This is going to be a really dumb question, I just know it, but I'm going to ask anyways because it's driving me crazy. How do I get acts-as-taggable-on to work? I installed it as a gem with gem install acts-as-taggable-on because I can't ever seem to get installing plugins to work, but that's a whole other batch of questions that are ...

How to combine formtastic with Ajax form submission?

I would like to use formtastic instead of standard Rails helpers for my forms, however I currently submit them using Ajax (with remote_form_for). I suppose I could use the jQuery form plugin to Ajax-ify formtastic forms, but would it be the best approach? ...

difference between three development modes in rails

What are the difference between three modes in rails like:- In development mode, Rails reloads models each time a browser sends in a request, so the model will always reflect the current database schema. EDIT I was asking about the other differences. I mentioned one i was looking for other list of differences...!! ...

Using sortable_element in Rails on a list generated by a find()

Hey all, I'm trying to use the scriptaculous helper method sortable_element to implement a drag-and-drop sortable list in my Rails application. While the code for the view looks pretty simple, I'm really not quite sure what to write in the controller to update the "position" column. Here's what I've got in my view, "_show_related_pgs.e...

"Invite your friends" feature in RoR

Hi, many social networks let to invite your gmail-hotmail-yahoo friends (even Outlook, but I thinks that is more difficult) to the social network. Basically the app read your email friends list and sent a email invitation. How can I achieve this in RoR? Thanks ...

Using open-uri how can I get the contents of a redirecting page?

I ultimately want to get data from this page: http://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=0656887000494793 But that page forwards to: http://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?execution=eXs1 So when I use open (open-uri) to try and fetch the data, it throws a Ru...

Rails nested association issue

Ok, so I'm new to both Ruby and Rails and I'm trying to do what I believe is called a nested association (please correct me if this is the wrong terminology). I currently have a User model and a Domains model and I have many to many associations setup (using has_many :through) between the two, and this works fine. I now want to extend t...

How can I persist sessions between a Ruby on Rails mongrel cluster and a Tomcat server?

Title says it all. I have a hybrid Ruby on Rails/GWT system and need to persist session data between the two servers, such that when a user is logged into the Rails system they are "logged in" to the GWT/Tomcat system, and vice versa. Anyone know of a simple way to do this? ...

rails: include statement with two ON conditions

Hi, I have tree tables books bookmarks users where there is a n to m relation from books to users trough bookmarks. Im looking for a query, where I get all the books of a certain user including the bookmarks. If no bookmarks are there, there should be a null included... my sql statement looks like: SELECT * FROM `books` LEFT OU...

How do I setup and utilize Shoulda, Factory_Girl, and Cucumber in a Rails 3 application?

I'm able to get my Gemfile how I like it: # Gemfile source "http://gemcutter.org" gem "rails", :git => "git://github.com/rails/rails.git" git "git://github.com/rails/arel.git" git "git://github.com/rails/rack.git" gem "sqlite3-ruby" group :test do gem "shoulda", :git => "git://github.com/thoughtbot/shoulda.git", :branch => ...

Surgical slave reads for Ruby on Rails, mulitple databases.

Greetings, I'm currently working on a multiple database rails application. I want to off load the SELECT queries on to the slave databases for only SOME of the databases or specific models. The issue is that in places, we swap out the current database connection and put in a different one for a short time; to load fixtures or to hand...

Having trouble sorting using Ruby on rails and acts as list, position won

I have Groups that has_many projects. I also created an order view that is similar to my Show view. The reason for creating an additional view is that I am using the Group#show view for a primary display in my site. So I have the following in my Groups_Controller def order @group = Group.find(params[:id]) end def sort @group...

Up to date (as of 2010) Ruby On Rails books?

Hello, I've been trying to learn Rails for a while now and I just can not piece it all together with random blogs and SO questions, so I've decided I need a full book/ebook. Can anyone suggest a good one? I've been looking at Agile Web Development With Rails 4th edition. There is an old question about Ruby On Rails books but it is from 2...