ruby-on-rails

How can I use Apache to serve static content for a RoR app when I have only .htaccess access (and can't add Apache modules) [on Dreamhost shared server]

Hi, Are there any Rails/Apache gurus that might know if it's possible (and how) to have the ability for users to upload their content to my RoR application but then subsequent access to such static content would be: a) served by APACHE web server [to avoid the overhead of going via Rails], but b) still want to have an authenticatio...

will paginate miscounting oddness with named scopes

I recently broke up my query into 4 named scopes to make it easier to re-sort and will paginate which otherwise always worked fine now has problems calculating the number of pages. named_scope :loc, lambda { |id| { :conditions => ['location_id = ?', id ] } } named_scope :datem, lambda { |*args| { :joins => :scannables, :conditions =...

Mechanize setting a field with a duplicate name...

I'm using mechanize and have a problem on one form... the form has two select boxes with the same name. How can I select the second one? ie. NumNights second occurrence. i found in the docs something like this: form.set_fields( :foo => ['bar', 1] ) but this didn't work: form.field_with(:name => [ 'NumNights', 2 ]).options[no_days...

cakephp or ruby on rails

Hi there I've put some of my free time on reading/learning about cakephp but now I'm wondering if will not be better to switch completely to ruby on rails. Can you give me the good and the bad of those tools, when is about web-development? many thx ...

How to use will_paginate with a nested resource in Rails?

I'm new to Rails, and I'm having major trouble getting will_paginate to work with a nested resource. I have two models, Statement and Invoice. will_paginate is working on Statement, but I can't get it to work on Invoice. I know I'd doing something silly, but I can't figure it out and the examples I've found on google won't work for me. ...

Agile Web Development with Rails Chap8:Sessions

I have completed chapter 7 successfully so far but now am stucked at Chapter 8: Sessions I m using rails version 2.3.2 I am following the instructions and code as written in the book but It is showing me the error of Token Authentiction Failed when i refresh store.rb to see the cart. how can i resolve this problem? i want to know from...

Rails Actionmailer Sending Email to Multiple Recipients that are Chosen from the View

Hi I am having trouble figuring out how to send email to a few different set groups with multiple recipients. I have many users, each user has an 'Inbox' found with their login name so something like: /users/c230in_cc/messages. The user can then go to "New Message" to send a message. Emailing one person is not a problem, I have that wor...

How to handle or prevent "Only post requests are allowed" error in Ruby on Rails?

I have a [somewhat] restful route setup with: map.resources :forgotten_passwords, :as => 'forgotten-passwords', :except => [:destroy, :show, :delete, :index] forgotten_passwords POST /forgotten-passwords(.:format) {:action=>"create", :controller=>"forgotten_passwords"} new_forgotten_passwo...

categories dropdown for product search

I am having many products with many categories which are associated with has_many using memberships. I am trying to create a search box where any one can search products while also filter their search with a category dropdown (so only products with relevant categories can be retrieved). The thinking_sphinx index is in Product model I d...

Specifying an empty or nil fixture in Rails

I have the ff. ActiveRecord which I use only for the ID it generates: class SomeTable < ActiveRecord::Base end I thought that one could specify fixtures for it through: one: two: Which I refer to in other fixtures as: other_one: some_field: some value some_table: one But when I run my tests, I get: Fixture::FormatError: Ba...

How do you access the session from within an ActionMailer class?

I have is an application can be accessed from 2 different URLs and looks/behaves slightly different depending on which URL you use to access it. I'm able to do this by storing a value in the session object and basing some decisions off of it such as which path views get loaded from. This sort of approach seemed like it would work until ...

Check FB Connect session expire using facebooker

Hi All, how to check whether FB Connect session is still valid or not using rails facebooker plugin ? Are there any helper or module that can check the session ? I figure out that if I open up 2 tab in browser, one login with facebook, another is with my site and login using FB Connect. When user trying to logout in my site, facebook wil...

How do ruby on rails multi parameter attributes *really* work (datetime_select)

I believe that datetime_select is black magic. What I'm really trying to figure out is the whole 1i,2i,3i,4i... multiple parameters stuff. Specifically how is it handled in the back end (activerecord, something else?). What's with the 'i' after the order-number? Is it a type-specifier? If so what are other types that are available? I...

Using Ajax to Replace A Page Element Based on an Onclick Event

I'm reformulating this question as I'm understanding the issue better now. I have an application with four models: Users, Products, Varieties and Seasons. User has_many :seasons has_many :products, :through => :seasons has_many :varieties, :through => :seasons Product has_many :seasons has_many :users, :through => :seasons has...

How do you use a partial in a layout template?

I have a partial that I'd like to use in a layout but when I load up a page it'll look in a different folder for the partial. So for my layout I've got. %html %head %body .content = yield .footer = render :partial => 'tracking' And in my layouts folder I have the partial file "app/views/layouts/_tracking.html.haml" that I...

Creating and testing a default record in Rails

I'm creating a user authentication system for my site. I want to add a default user, so that if I create a new site, or reset the database I will still be able to log in (and change the default user details). I have the code below in the migration. All seems to be working fine for the development database, but when it come to testing th...

Why are associated objects through a belongs_to not equal to themselves?

I have two classes with a has_many and belongs_to association: class Employee < ActiveRecord::Base has_many :contracts end class Contract < ActiveRecord::Base belongs_to :employee end I expect that the employee returned by the #employee method of the Contract class would be equal to itself, which means that the following unit test...

How to set RAILS_ENV in Aptana Rad Rails?

I'm using Aptana RadRails, and it seems that whenever I do any rake tasks it is using the development environment. How do I tell it to use the production environment? (e.g. db:create sets up my development database. I know I could do a db:create:all, but I'm wondering how to set the environment.) Thanks! ...

Ruby On Rails & XMLRPC w/ OpenX

I am using xmlrpc to make a rails app communicate with an OpenX ad server. The OpenX ad server starts a session on the 1st request and associates the session with the class, not an instance of the class. The session is associated with the class, and not an instance of the class. Classes in Rails applications persist past the end of a re...

Ruby on Rails tutorial problem

Quick question which I hope is easily answered.. I am following this tutorial: http://oreilly.com/pub/a/ruby/archive/rails.html?page=2 and all is going well until I try create a controller and view it in my browser. The server is running and it shows the default page okay (http://127.0.0.1:3000). I ran ruby script\generate controller ...