ruby-on-rails

Rails 3 and Rspec 2 turn off transactional fixtures for individual tests

I am in the process of upgrading my application to Rails 3. I started using Rspec 2 with Rails 3. I need to turn off transactional fixtures for some of my rspec tests. Prior I used the following code in my model specs before(:all) do ActiveSupport::TestCase.use_transactional_fixtures = false end after(:all) do ActiveSup...

Delayed_Jobs will not refresh

I had previously a mailer set up to send me emails to all user accounts. But now I'm trying to debug it. So I gutted it out completely and it still sends emails to me. I have absolutely no reasoning or understanding as to why. Insanity! :D controller def org_blast_send Delayed::Job.enqueue OrgBlast.new(params[:subject], params[:edi...

Best practice for drying up the display of the same model data on almost every page

I'm developing a classified ads site which will have display same sidebar on almost every page. A list of categories which are fetched from the database. I find myself duplicating the same code in each controller to do this. i.e. before_filter :load_categories Where :load_categories performs a simple private def load_categories ...

Rails, Cucumber: external redirection to another domain

I have cucumber feature ... Given I am on my domain page When I press "send data to external domain" Then I should be on the externel domain page ... In production and development enviroments "My domain page" (www.example.com/mydomainpage) redirects user to "external domain page" (www.externaldomain.com/page). But in test enviroment c...

Rails app, upload via API, test via curl

How can i make my photo rails app to receive images (and handling them with paperclip) through the built in API using paperclip plugin. My app works fine when upload from browser..How can i test the API with curl command? How can specify the end-point url? thanks. ...

How can I merge and order multiple lists together using Ruby?

I have 2 lists that have dates and data. Each list is in the proper order as noted by the sequence number. Now I need to merge the 2 lists together and keep everything in the correct order. For example: List A 20101001 A data 1 seq1 20101001 A data 2 seq2 20101005 A data 3 seq3 List B 20101001 B data 1 seq1 20101003 B dat...

Rails, allowing users to create a form that will be used by other users.

Hey Guys, Hope someone can help me out. Currently working on a RoR project that needs a strange kind of functionality. Basically, I have two types of users named User and Researcher. Users can create forms and these forms are stored in the db and filled in by researchers. I have this basic schema create_table "form_fields", :force =...

Adding a "Like/Unlike" button to a post in Rails

Hi, The site is a simple community where each user creates posts and users may "like" them or "unlike" them. I have a Post and a Like model. Currently, I'm listing all posts and also the likes size for each post through post.likes.size . The button to like a post is also working. What i don't know how to do is how to depending on the...

Rails, Radiant, and Regex

I'm working on a Rails site that uses the Radiant CMS and am building stateful navigation as per the first method in this link. I'm matching the URL on regular expressions to determine whether or not to show the active state of each navigation link. As an example, here are two sample navigation elements, one for the Radiant URL /commu...

Adding "Featured Posts" to my blog...

I am trying to add a featured post feature to my Ruby on Rails Blog. So far I have added a featured_post column to my post table and it passes a 1 if the check box is selected and 0 if not. Now I am attempting to pull out these posts by doing the following: /views/posts/index.html.erb <% @featured_post.each do |post| %> <%= pos...

SwfUpload's params are not set correctly

I'm renovating an application to work through AJAX. Unfortuantely, the action url in my form is getting messed up somehow. Do you know why this is? Currently my swfupload param of : upload_url: $('#new_video').attr("action"), is returning a SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 302. SwfU...

rails 2.8 restful routes with no models?

How can I make a controller restful when it does not have a model? I have the following controller called programs, and I want it to be restful so that: rake routes | grep programs will show me a complete list of methods. Currently I only have: new_programs GET /programs/new(.:format) {:controller=>"programs"...

Rspec not displaying colours

I'm running Rspec 2.0.0rc on Windows 7. I am also running the win32console gem (1.3.0 x86-mingw32). The colours aren't being displayed - everything is showing up in boring old white/grey. What am I doing wrong? Edit: I also tried Rspec 2.0.0. and had the same problem ...

Authlogic: Setting expiration date for cookies

Is there a way to set the expiration date for the session cookies created by Authlogic? ...

how to set value of request.user_client

Hi in my tests i have get "/" and inside controller I have action that depends on browser When I run my test it fails because request.user_client is nil What can I do to fix this problem ? ...

Reading rails text_field names with javascript

Here is what I'm trying to do <% form_for @color, :html => {:multipart => true, :name => "color_form"} do |f| %> <%= f.text_field :head_color %> and I want to use this javascript document.color_form.color[head_color].value; javascript obviously doesn't like this and throws an error. The problem is that I can't use text_field_tag. ...

Why isn't url_for rendering this like I think it should?

I have this in my controller: @statics = [{'home' => 'about'}, {'home' => 'termsandconditions'}, {'home' => 'information'}, {'news' => 'archives'}] and in my view: @statics.each do |controller, action| xml.loc url_for(:only_path => false, :controller => controller, :action => action) xml.lastmo...

Thinking Sphinx search with two classes and eager loading

I use TS to search trough 2 models (classes) at the same time: class Product < ActiveRecord::Base belongs_to :user belongs_to :photo has_many :variants end class Article < ActiveRecord::Base belongs_to :user belongs_to :photo end In controller: @item_facets = ThinkingSphinx.facets( options[:search], ...

jqTouch form submission issue (rails 3, devise, jquery, jqtouch, ios 4)

I've been playing around with jqTouch to create a mobile version of my Rails app. I use Devise for authentication, but it won't work with jqtouch. It has something to do with jqtouch's "auto-ajax" functionality. I used a "rel=external" attribute on my sign in form to get it to do something at all (before it simply wouldn't do anythin...

Rails - Iterating through nested arrays

Hi I'm very new to rails and need some help on iterating through nested arrays. I'm trying to figure out how to do mass-inserts for each values that is different between the make, model and color of cars. The params that are pass are: "make" => ["Honda", "Honda"], "model" => ["Civic", "Accord"], "color" => [{"Black", "White", "Red"}, {...