ruby-on-rails

How to find topics with the most flags

Let's say I have a model called Topic. A Topic has_many :topic_flags (a TopicFlag is used to denote content that has been flagged as inappropriate). My question is this: how can I select the Topics with the most flags (limited at an arbitrary amount, descending)? I've thought about it for a while, and while I can hack together an SQL que...

XMLRPC problem with a Rails app

I'm trying to access an XMLRPC API (for the Magento PHP app) from my Rails application. I'm using a gem however whenever I try to connect on my local machine (Snow Leopard) I get this error: no such file to load -- xmlrpc This is triggered by a line require 'xmlrpc' Is there a specific Ruby XMLRPC gem I need to install? Sorry for the...

Benefits, etc of using mySQL over SQLite (RoR)

I'm building a web application right now for my company and for whatever reason, can't get mySQL working on my Mac w/ my Ruby install (OSX 10.5). SQLite works fine though, so would it be a problem to use SQLite for now so I can get to work on this and then just change up my database.yml file to point to a mySQL database when I deploy (a...

Polymorphism and forms in Ruby on Rails

I've been full of questions lately, but thanks to this awesome community, I'm learning a ton. I got all the help I needed with polymorphic associations earlier and now I have a question about tackling forms with polymorphic models. For instance I have Phoneable and User, so when I create my form to register a user, I want to be able to...

Rails Error - No Such File to Load -- mysql

I've been fighting with a Rails install on my Mac for some time. The error I'm getting (in my development log) says: Status: 500 Internal Server Error no such file to load -- mysql Here's some info: I can successfully rake db:migrate my application I've installed the MySQL gem and it appears in the gem list: mysql (2.8.1) I have Pass...

Rails: Using form fields that are unassociated with a model in validations

In a Ruby on Rails application I am trying to use information from fields that are not associated with the model in validation. Here is part of the model as an example (the whole model has gotten kinda big): class Scorecard < ActiveRecord::Base belongs_to :course belongs_to :user validate :attributes_consistency def attribute...

number of guests in ruby on rails

Is there an easy way to count the number of active users or guests (not logged in users) visiting my rails app? Right now I have a way to count the number of logged in users in the last 15 minutes by having a last_seen_at column for the user. However I don't want to use the database to figure out the total number of active users or gue...

IronRuby on Rails with IIS 7

I'm trying to get a Rails app built with IronRuby running on IIS 7. I followed all the tutorial given on the IronRuby site but I can't seem to get it to work. The app runs fine hosted under WebBrick but IIS doesn't seem to host it properly. Here is the page I get. Error: exit C:/repositories/RampUp/ruby/RampUp/config/boot.rb:66:in `exi...

escape characters <%= h("") %> and how to deal with double quote ruby on rail

Hi, This might be a simple question to answer, but I couldn't find the answer. In ruby on rails, I thought the helper function would help escape special characters. Example: " She's the one that took me "to" " Code wise: <%= h("She's the one that took me "to" ") %> However, the double quote won't allow me to display the code on the...

Understanding REST conceptually with Rails

I'm a little late to the party, but I'm trying to wrap my brain around how REST is supposed to work, both in general and in Ruby on Rails. I've read a bunch of articles online about this already, but still don't feel like I'm getting the big picture. REST as I understand it, is a series of aspirational statements, with the net result at...

How to Write hyperlinks using spreadsheet gem in Ruby?

The spreadsheet gem isnt documented properly, so I cant understand how can I write hyperlinks using spreadsheet gem. Can anyone tell me? ...

how to implement the mturk on rails application

how to make controller , view , model for mturk on rails application ...

Dropdown list in Rails tied to a different model

Hello, I have Category and a Product models. I want for each product to belong to a category. How would I have a drop down list so that you can select a category from the product pages? I've gotten everything to work with this: <%= collection_select(:category, :id, @categories, :id, :title, options ={:prompt => "-Select a category"}, ...

How to nuke all Ruby Gems from the system and start over

What's the easiest way to start over with Ruby Gems? I have Ruby 1.8.7 (OSX, ports) installed and I have also installed rails and some other random stuff a while back. Now the gems system seems to be totally dysfunctional and I can't upgrade rails. So is there a way to just nuke the gems so I can reinstall all this stuff with current ver...

how to send a parameter not associated with the model object using form_for in rails

I use form_for to save a model object site <% form_for :site :url => {:controller => 'site', :action => 'add_site' } do |f| -%> <%= f.text_field :protocol, :size => 127, :style => 'width:255px' , :value => "http://"%&gt; <%= f.text_field :site_name, :size => 127, :style => 'width:255px' , :value => "www."%> ...

Trying to get Warehouseapp to work on Windows

Hi, I have downloaded and am trying to run warehouse app http://warehouseapp.com (a subversion front end). I have got xampp installed on my Windows Home Server and I have it working on port 80. I have set up the ruby on rails server using this guide grapethinking.com/getting-rails-to-work-on-a-windows-machine-running-xampp I copy the w...

Increase reliability of capistrano deploys

I've used capistrano for a long time, but always for sites that weren't critical. If something went wrong, a few minutes of downtime weren't a big problem. Now I'm working on a more critical service and need to cover my edge cases. One of which is if my local connection to a server becomes interrupted in the middle of a deployment. One...

How do I connect jQuery Datepicker to my Ruby on Rails form?

I'm trying to use the jQuery Datepicker to set a date field in my Ruby on Rails form, but I can't work out how to do it. Can someone point me in the right direction? ...

How can I set a constant with namespace in the initializers?

Help! in my rails controllers, there is a 'Admin' namespace. (My the structure of the controllers dir is like this : app/controllers: home_controller.rb ... admin/posts_controller.rb admin/pages_controller.rb The 'Admin' will automatically become a Module constant (I know it from the console: 'puts Admin => Module'); And...

rails - root model or application model

Hey, I was just looking around rails and noticed there is an app controller but no app model. Is there no root model in rails ? if not where do you put a piece of code that needs to be in every model. Thanks, Alex ...