ruby-on-rails

How to accept a put request in rails.

I am trying to build a survey app in rails 3. Basically I need to make a wa yi to accept responses from a set of questions. (surveys have many questions and responses.) I got it to render but when I submit it it sends as a put instead of a post. So is there any way I can add a custom put route to my response controller? ...

One model and controller but slightly different views and routes in rails3

I have a model Notifications, and it basically handles the same few things. A simple contact form, an invitations form, etc. They all have the same generic items... ie Name, email, comment, blah. There might be one slightly different field but they are optional, so I'd like to treat them as one model with a differentiating field calle...

how to implement live search like 37signals job board

I'm a rails beginner and am curious how the live search on http://jobs.37signals.com is implemented? I can understand the background but not the front end. what I understand: after certain # of characters have been typed, a request is made to backend with the phrase as search term do a database search where job description like '%_p...

counter_cache not decrementing for has_many associations in ActiveReord

My Rails 3 app has 2 models and a third that's join table between them and their has_many relationships. Basically, User and Show are joined by SavedShow, allowing users to save a list of shows: class Show < ActiveRecord::Base has_many :saved_shows has_many :users, :through => :saved_shows end class User < ActiveRecord::Base has_...

How do you seed models with HABTM relationships to other seeded models.

I'm working on my first Rails(3) App, and looking to seed a bunch of data. The issue I'm having is that I want to seed some models that have a has_and_belongs_to_many relationship with other models I've just seeded. I'm doing what seems right, but I'm not getting the results I'm expecting. I have an Asana model (simplified): class As...

Ruby OAuth Nightmare: Using Contacts API

Hi there, I've been spending the last few days banging my head against the wall on supporting the ability to add a contact to the Google Contacts API in my Rails 3 application. Despite many false starts, I've finally made some progress by employing the Ruby OAuth gem, and following the tutorial here: http://everburning.com/news/google-an...

Rails 3 - How to Create a Record if One Does not Exist OR Update the existing records

I'm creating a permissions table for People & Books In the permissions table I have: Permission.ID, user.id, book.id I want an admin to be able to set permissions for Users<>Books. When the user selects the permissions and clicks submit, in the Rails controller, should I be submitting to /create or /update? is there a way I can subm...

Authlogic sends the wrong activation code

Update: this question has been answered (see below). I'll leave it up in case anyone can benefit in the future. I am trying to get e-mail confirmations working on Authlogic using Rails 3. http://github.com/matthooks/authlogic-activation-tutorial Authentication is working and the activation e-mails are being generated and sent, each c...

Rails 3 - Issue with Nested Routes, It's not allow for a custom collection?

Hello, I have the following in my routes.rb: resources :projects do resources :photos, :permissions collection do get 'yourcurrentprojects', 'userprojectpermission' end end But when I do, projects/3/permissions/userprojectpermission i get a routing error: No route matches "/projects/3/permissions/userprojectpermissio...

Error calling Dispatcher.dispatch #<NameError: uninitialized constant ActionController::CgiRequest

I'm getting the following error on log/mongrel.6001.log I'm using mongrel_cluster , rails 3 and ruby 1.8.7 I start mongrel_cluster using mongrel_rails cluster::start But when I try to access the page on browser I get the error bellow "Error calling Dispatcher.dispatch # Mon Oct 11 00:26:04 -0500 2010: Error calling Dispatcher.dispat...

Is there a Rails way to check which attributes have been updated in an observer?

I have an ActivityObserver, which is observing tasks, and has an after_update callback. I want to test if a particular attribute has been modified in the update. Is there a Rails way to compare the attributes of the subject with what they were before the update, or to check if they have changed? ...

Merge branch 'user' in git log

Hi , I am working in ROR in a Ubuntu machine. I had done some changes in my files and commited it with a msg. Now when i checked with the git log thing.. I am getting a new msg rite above my commited message as Merge Branch 'myname' .. Why is it so coming like this ? Please give suggestions.. EDIT : Date: Mon Oct 11 11:42:29 2...

Is it okay to add database indexes to a database that already has data?

I have some data in my production database already. If I'm adding some database indexes on a few fields, is that a problem? Rails 2.3.5, Ruby 1.8.7, sqlite3 database ...

rails: pass value of a text field to a helper function

I'm sure this is a basic question... I have a nested form where the nested object contains a text field. There is a link_to_function in the form that calls some javascript. I want to pass the javascript function the value of a hidden field in the form (image_type_id). Can I reference this with some ruby or does this need javascript? ...

If a URL doesn't have a filename in it, can I determine if it is leading to an image?

This URL takes you to an image, but has no file extension to check a regex against: http://www.tonymooreillustration.com/gallery/main.php?g2_view=core.DownloadItem&amp;g2_itemId=393 I'm using Restclient (HTTP and REST client for Ruby) in my app, so I tried doing this: RestClient.get "http://www.tonymooreillustration.com/gallery/main....

ActiveRecord::Relation error

Error from Rails, does this make sense to you? <%= @permission.inspect %> outputs: [#<Permission project_id: 3, role_id: 2, user_id: 13>] <%= Role.find(@permission.role_id) %> undefined method `role_id' for [#<Permission project_id: 3, role_id: 2, user_id: 13>]:ActiveRecord::Relation This doesn't work either for some reason: @permis...

Using authlogic, login using email and password was working fine. I just added a username field to my User model, and now login doesn't work.

I use authlogic in my RoR app. For login, I use email and password like this: <% form_for @user_session, :url => user_session_path do |f| %> <%= f.error_messages %> <%= f.label :email %><br /> <%= f.text_field :email %><br /> <br /> <%= f.label :password %><br /> <%= f.password_field :password %><br /> <br /> <%= f.check...

Rails won't save my foreign key to the database

So basically I have two models, Entry and Comment. I have the association setup so that Entry has many Comments: class Entry < ActiveRecord::Base has_many :comments end And a comment belongs to an entry: class Comment < ActiveRecord::Base belongs_to :entry end In my database schema I have setup the comments table with a column call...

Rails Load a icon which isn't saved in the images folder

Hi, I wand to give a preview of the just uploaded pictures. These pictures are not saved in the public folder, as they are not public... How can I do this? Thanks Markus ...

Ruby on rails - javascript current locale

Hi! How a javascript can get the current locale in ruby on rails application? ...