ruby-on-rails

Rails: best practice to scope queries based on subdomain?

I'm working on a Rails (currently 2.3.4) app that makes use of subdomains to isolate independent account sites. To be clear, what I mean is foo.mysite.com should show the foo account' content and bar.mysite.com should show bar's content. What's the best way to ensure that all model queries are scoped to the current subdomain? For examp...

Getting a strange nil in Rails with Select

I'm getting a strange nil problem with the following code. The view (part of it): <p> <%= label :maintenance, :name %> <%= text_field(:maintenance, :name, :size => 20) %> </p> <p> <%= label :maintenance, :type %> <%= select :maintenance, :type, @m_types %> </p> If I remove the text_field or move it below the select, I get a ...

Testing associations with cucumber

Hi there, I'm new to rails and cucumber and I'm trying to test the following scenario Background: Given I have a Group named Group 1 And I go to the list of groups And I have the following users records | name | description | group_id | | user 1 | | 1 | | user 2 | | 1 | When...

How to read and image and get blob in ruby

I am using a homegrown captcha system. This uses Rmagick and Rmagick comes with ImageList. Existing code is like this. im = ImageList.new("#{@@captcha_image_path}/#{captcha.pos}.JPG") @imgdata = im.to_blob send_data(@imgdata, :filename => 'captcha.jpg', :type => 'image/jpeg', :d...

getting tables to work is RadRails?

When I manually enter tables into the .rb file in the migrate folder nothing shows up. I have followed a few different "how to's" but I can't get the tables to show up when I preview my work. I can however get one table to show up if i create it in the parameters when generating a scaffold, but that's one table. I have Rails version 2.3....

Sending a code block to a find_all dynamic method

I'm working with some complex queries using the dynamic find_all method and reached to a point where sending a block to that find_all method would really simplify my code. Is there any plugin or work in-progress dealing with this? In simple terms, I'd like to do something like: @products = Product.find_all_by_ids(ids, .....) do |p| ...

gem update sqlite3-ruby fails on Mac OS X 10.5.8

I was trying to get the latest ruby on rails for my Mac running OS X 10.5.8. All went well until I tried to update the sqlite3-ruby. I see that others have had similar problems, but they were on Windows. This is the error: sudo gem update sqlite3-ruby Updating installed gems Updating sqlite3-ruby Building native extensions. This could...

What is the best way to design database for Ruby on Rails?

I know there are many database design tool, database modeling tool. Example, ER-win , db desginer and etc. But, they are not supported for Ruby on Rails. What is the best way or tool to design database for Ruby on Rails? Appended: I know the rails development phases are growing step by step. But, When starting of project, I think da...

How to export data into a prn file (fixed width with space fill) in Rails

I did not see this kind of task done anywhere and was wondering how I could export data in a .prn file format in RoR. The idea would be to have: field 1 -> length: 6 chars -> content: "blah" field 2 -> length: 8 chars -> content: "foo" field 3 -> length: 4 chars -> content: "bar" and convert it to a line which would be like: "blah...

How do I check between 2 arrays of different objects?

I want to check if a claim's items has assets in it and @item_assets basically gets all the items in the database that are classified as assets. When doing the following: >> @claim.items => [#<Item id: 8, name: "chair", amount: 10.0, gst: 0.7, override: false, item_category_id: 7, item_expense_id: 8, claim_id: 8, club_id: 71, created_a...

Convert Ruby Code To PHP Help Please

Ruby Code: # Turn hash input into JSON, store it in variable called "my_input" my_input = { "itemFilter" => { "keywords" => "milk" }}.to_json # Open connection to website.com @http = Net::HTTP.new("website.com") # Post the request to our API, with the "findItems" name and our JSON from above as the value response_code, data = @ht...

Authlogic - Authentication via basic HTTP authentication

Hello everyone, I want to use "authenticate_ with_ http_ basic" but I just can not get it working. In my RoR app Authlogic is working fine and I'm using User Sessions for that. While keeping that method as it is now i need to use authenticate_with_http_basic.I have a iPhone SDK app and now I need to fetch some products from my webapp a...

Seeking suggestion for my graduation project in Web development

Hello . I have to confirm the detail of my gradutaion project recently. My setup a goal for myself, that is it should have values( maybe as a opensource project or tools that can be use by others). Can you suggest some ideas or projects pertaining to one of : Web architect, Social Media, Ruby, ROR, Testing. Thanks!:D ...

Running multiple background parallel jobs with Rails

On my Ruby on Rails application I need to execute 50 background jobs in parallel. Each job creates a TCP connection to a different server, fecths some data and updates an active record object. I know different solutions to perform this task but any of them in parallel. For example, delayed_job (DJ) could be a great solution if only it c...

CruiseControl.rb always running my projects in production mode?

I'm curious as to why when I build my project using CruiseControl.rb, it runs it in production mode? Even though my application should not be in production mode. I even tried to specify: ENV['RAILS_ENV'] ||= 'development' in my app's environment.rb ...

Generate an new user programatically (Auth Logic)

Hi, I'm quite new to Ruby on Rails so please bear with me :) I'm processing an imported .csv file in Rails and I want to programatically create new users (I'm using the AuthLogic Gem along with Role Requirement), So Far I'm using: Example Line: [email protected], Steve, Jobs, 555-APPLE Code: def new_user(line) params = ...

If else or case statement help!

Hi I could really use some help with the best way to accomplish the following: I have the below in my controller (and I know this should not be here and needs to move to the model) This is an email messaging system so according to what position you hold you are able to email out to set groups of people. So if you are Battalion Commande...

How to monitor traffic of ruby on rails website?

I have a ruby on rails application and it would be nice to see how many hits I get per hour. Is there some simple free software to do this or do I have to develop a custom solution? Thanks! ...

File upload in Rails- data is an object, how do I return it in my view?

When doing an upload in my Rails project, the database stores --- !ruby/object:File content_type: application/octet-stream original_path: my.numbers how do I get it to return my.numbers in my view only? Thanks a bunch! Marco ps. I don't want to use attachment_fu or any other plugin preferably. ...

Rails not loading CSS/javascript/images on ISP server

I have a Rails app that works fine on my local environment. But when I upload it to my ISP the app is not loading any of the assets in the public directory. Because the ISP uses .htaccess rewrites for Rails apps, I suspect this is the problem, but I'm pretty green on that sort of thing. On the server, my rails app is deployed at ~/etc/r...