ruby-on-rails

Integration testing Rails API with basic authentication

I'm trying to get a test signing in using basic authentication. I've tried a few approaches. See code below for a list of failed attempts and code. Is there anything obvious I'm doing wrong. Thanks class ClientApiTest < ActionController::IntegrationTest fixtures :all test "adding an entry" do # No access to @request #@requ...

Problem with mysql2 and rails3 (bundler)

Hello, I get this error `establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError) from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord- Here is dump of whole error and my config ...

Gemfile group is used for?

I know the "group" method is used for specify gems for specific environments. group :development, :test do gem "rspec-rails", ">= 2.0.0.beta.19" gem "cucumber-rails", ">= 0.3.2" gem "webrat", ">= 0.7.2.beta.1" end But I dont get what it means. So these could just be used when im in development and test environment? But will it ...

Rails 3 model associations. Limit the number of data selected

I have a model user, a feed, and a comment. user has many feeds and comments, feeds belong to user and have many comments and finally comments belong to user and feed. No when i show feeds for a certain user, it selects all the comments made till date for every feed. I want it to select only those comments that were made in the last 1 m...

nested attributes and habtm checkboxes working on same form?

Hi I have a task model which has a habtm association with documents, I want the user to be able to upload new documents and automatically associate those documents with the task and also be able to select existing documents to link or unlink with the task I've tried using the nested attributes code and the habtm checkbox code from rai...

How can I use Cucumber to test Devise's Rememberable functionality?

I'd like to have a Cucumber feature testing the rememberable functionality of devise (a remember me cookie). It is easy to check the remember me check box using capybara but how should I simulate a user returning to the site after closing their window? ...

Dynamically adding fields to a nested form and index generation

I'm trying to build a nested form similar to the one here: http://railscasts.com/episodes/197-nested-model-form-part-2 The form is for creating an invoice with items that can be added dynamically: <div> <%= render :partial => 'invoice_item_fields', :locals => { :f => f } %> </div> <tr id="invoice_items"> <td colspan=3> <%=...

Rails 3 - wkhtmltopdf command failed when using PDFKit to create PDF documents

Hello, I have setup PDFKit in my Rails 3 application, using RVM (had to manually copy the wkhtmltopdf binary). When I try to render the PDF version of a page, I get this error: RuntimeError in AgenciesController#show command failed: ["lib/wkhtmltopdf/wkhtmltopdf", "--disable-smart-shrinking", "--page-size", "Letter", "--margin-top", ...

Updating several model instances at the same time, The Rails Way?

I have a settings table with two fields, key and value. Now, while creating an administration section for it I want to be able to edit all settings at once. Is there a "Rails (3) way" to do this that will save me some time? ...

no password_confirmation on create but need it during update (authlogic)

I am quite new to rails and I am using authlogic for my authentication system. I want to have password_confirmation when user updates his profile, but not when he is signing up. I figured out this config option acts_as_authentic do |c| c.require_password_confirmation=false end When I do this, it ignores password_confirmation during...

Rails 3.0 Engine - Execute code in ActionController

Hello all, I am upgrading my Rails plugin to be an engine that works with the latest 3.0RC1 release and I'm having a bit of trouble figuring out the best (and most correct) way to extend ActionController. I've seen this post by DHH and this question here on SO, but my question is more about how to properly call code within the ActionCon...

jQuery.noConflict() method causing problem in my App

Hi, I am using jQuery in my Rails application. I wanted to add a expand collapse text effect in my page. So I downloaded the jQuery exapander plugin and tried to use it. I am facing a weird problem. My jQuery.js file is having this line called jQuery.noConflict(); at the end. I have to remove it to make this expand collapse effect to w...

Ruby on Rails: Search logic query gives MySQL ambiguous column error

Search logic is automagically doing an INNER JOIN on one the tables in my DB, is there a way to get it to specify to not include the user column in that second table? ...

restful authentication current_user

Is it available in the controller, because it's not working for me. ...

Rails, CookieStore vs ActiveRecordStore

Hello, I am currently experiencing a strange issue with our users being logged out. I haven't been able to reproduce it explicitly. The Rails application is using the default CookieStore. My initial hypothesis is that somehow the session data within the cookie, or even the cookie itself is being destroyed. This may be either from a use...

(rails3) passing ruby variables to javascript file

When rendering a javascript file (not RJS, just a regular JS file) from a rails controller, is there a way to pass variables to it, which can then be used by functions in the JS file being called? I've tried :locals => {} but that doesn't work. ...

jQuery ajax filters on a sortable table in a Ruby on Rails application

I am looking for a tutorial or documentation on how to create sortable table with filters in Rails application without using any jQuery or rails plugins. I want to use jQuery as javascript library and not prototype. All what I found in the internet is using one or the other jQuery plugin. ...

named_scope and HABTM association

Hi all, I have a models User class User < ActiveRecord::Base has_many :ratings has_many :rated_films, :through => :ratings, :source => :film end and Films class Film < ActiveRecord::Base has_many :users, :through => :ratings end I am looking to find all Films that have not been rated by the specified user...

related objects in steps with cucumber/pickle

Hi, it would be great if somebody could help me with the cucumber/pickle syntax on creating related objects and assert them. How can I get references in my cucumber syntax... Something Like For example: creating a blog post with a certain title with 3 comments And then assert this post and the related comments... Is this with object ...

Can I disable backgroundRb database usage?

I would like to use backgroundRb but without having to modify my db schema. I am not interested in the persitent job queue, just running long tasks in the background from a Rails application. Regards! ...