ruby-on-rails

undefined method ‘where’ RoR error.

I am working on the depot tutorial in Agile RoR. I have looked at this for a while and don't see an error. What am I missing? I get the following error when I add an item to a cart I have run the migration. .. /Users/computername/.gem/ruby/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:376:in ...

Understanding Agile

Hi, I recently shifted to a new organization that follow Agile mode of development. The current project we are working has stalled due to many requirement changes that were reported recently. Since this is my first Agile assignment (after working in 4 years in non-agile environ), its a bit hard to differentiate where the problem really ...

Ruby on Rails or programmatically generated <span> or <img>, each on a line, causing spaces in between when displayed

When using Ruby on Rails or other framework, a lot of time we generate <span> or <img> in a loop, and each line will be on a new line. So when it is rendered in HTML, there will be extra space between those inline elements. How can it be solved? Must they be made into 1 long line, or solvable using HTML or CSS? ...

Using Unobtrusive JavaScript to Update an Element

As you know, when you upgrade from Rails 2 to 3 you replace this: link_to_remote "more", :url => {...} with this: link_to "more", {...}, :remote => true But how do you handle the :update option in link_to_remote? In Railscast #205 Ryan Bates demonstrates link_to with :remote and a server response that includes JavaScript code to up...

No such file to load -- zip/zip (MissingSourceFile) when running cucumber

Hello, It was been a long time I haven't run cucumber in my project. It's running good before but now, when I try to run cucumber features, I have this error: Using the default profile... no such file to load -- zip/zip (MissingSourceFile) /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/...

How do i add the authenticity token?

I recently switched to Google closure for a new project. I am having trouble adding the authenticity token to the headers in a ajax call. How do i go about it? My Ajax snippet (using goog.net.XhrIo class): var initialHTMLContent = superField[i].getCleanContents(); var data = goog.Uri.QueryData.createFromMap(new goog.structs.Map({ bo...

Rails and JQuery - can't disable a links default action.

I have a "checked" link which goes off to the same names controller action. Its routed as a POST request. Ive setup up the code but whats happening is the jquery $.post fires as wanted but the html request also happens meaning my action is being called twice. I can't figure out why. Can anyone spot a mistake im making? In my applicati...

Deploy:symlink on capistrano points the "current" directory to previous release

Hello, I am using capistrano to deploy my Ruby on Rails project. I am on a Dreamhost VPS and since a few weeks ago, with no change in capistrano or passenger, I began to experience a strange problem with the deployment: Every time capistrano is deploying my application, everything goes right except deploy:symlink (which is called by de...

Activerecord join with has_many :through

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'schedules.id' in 'on clause': SELECT `schedules`.* FROM `schedules` INNER JOIN `shops` ON (`schedules`.`id` = `shops`.`shop_id`) INNER JOIN `areas` ON (`areas`.`id` = `shops`.`area_id`) The correct sql statement should include 'schedules'.'shop_id' = 'shops'.'id' inst...

Rails 3 CRUD shallow nested model

Hello ! I'm trying to use this example but it doesn't work. I guess it's because I use a shallow nested model ! I get this error : Template is missing Missing template pprojects/create with {:formats=>[:html], :handlers=>[:builder, :erb, :haml, :rjs, :rhtml, :rxml], :locale=>[:en, :en]} It looks like my app is trying to do HTML and no ...

Setup a testdirectory for a Rails Plugin

Hi. I started to create a rails plugin which includes some class and instance methods of Controller and Model. I fist tried to setup the tests for the Model. Add a models directory in my test dir. But i noticed - i need the geokit-rails plugin for my model to be able to "acts_as_mappable" How to get the plugin into the test dir? I try...

DelayedJob and `master_slave_adapter`; losing the master connection

We have a Rails application that is running in a MySQL master-slave set-up for a while now, using the master_slave_adapter plugin. Recently, there was a need for background processing of long running tasks. So we settled on DelayedJob. DelayedJob's table/model uses the same master-slave adapter. And it keeps the slave connection alive b...

How do I build this JSON object in ruby?

I need to bring an array of ruby objects in JSON. I will need to find the item in the JSON object by id, so I think it is best that the id is the key of each object. This structure makes the most sense to me: { "1": {"attr1": "val1", "attr2": "val2"}, "2": {"attr1": "val1", "attr2": "val2"}, "3": {"attr1": "val1", "a...

Ruby on Rails: How do I update a plugin in my apps vedor directory?

Title says it all ...

Files in gitignore

I have a repository with a rails app in the production Server. In the repo there is the .gitignore file: ... config/database.yaml ... Every developing client have a cloned repo with different config/database.yaml. My problem is this: database.yaml is in .gitignore, then when I run git clone (on the server) the database.yaml wi...

Test page helpers in rails app

I have some page helpers in application, something such as: # ajax_helper.rb module AjaxHelper def update_counter(new_value) page.replace_html :counter, :partial => 'counter', :locals => { :value => new_value} end end # update.fbjs.rjs .... page.update_counter(new_value) ..... What is the best way to test this helper method? ...

ActiveRecord::Base.connection.update(sql) sometimes returns incorrent number of affected rows

I have a production web site with the following environment: Rails 2.3.5 MySQL Server 5.1.33 Enterprise Ruby 1.8.6 (2008-08-11 patchlevel 287) [x86_64-linux] mysql gem 2.7 Old version of BackgrounDRb plugin running on 4 different servers for background tasks, with 5 different workers each (Ruby threads, not separate processes!). One ...

[Rails] map.resources with alternate primary key(s)

I have a Rails model Object that does not have an ID column. It instead uses a tuple of primary keys from two other models as its primary key, dependency_id and user_id. What I want to do is be able to do something like this in routes.rb: map.resources :object, :primary_key => [:dependency_id, :user_id] And for it to magically genera...

Help with rails collection_select [edited]

I have been trying to implement this jquery plugin to my app.I need help trying to output something like this <select name="user[university_id]" id="user_university_id" class="selectable"> <option value="1" title="uni1">Uni1</option> <option value="2" title="uni2">Uni2</option> </select> by using a rails helper...the problem i...

Need for Rails plugin management tools?

Hello, I've been searching for a while, and I can't find any modern rails plugin management tools. I found several gem management tools (such as bundler and isolate), but no plugin management tools. The closest thing to that I found was piston, and that's not exactly what I was looking for was it was for plugin svn:externals managemen...