ruby-on-rails

Selecting a Rails host

I'm close to picking a Rails host. I think I need a VPS solution, because (1) my Rails app has gems and plugins that I need to install to get it working, and (2) I need an SMTP server to send emails from my rails app out to users. But then it occured to today... 1) Do I actually need VPS and root access to get my app up and running, ju...

Ruby On Rails ActiveRecord model not showing "blacklist" field

So I'm trying to rough out a design in Ruby, and so I ran ruby script/generate scaffold item name:string description:text model:string manufacturers_name:string category:string weight:decimal upc:string ebay_cat_id:string blacklist:bool in_discovery:bool archived:bool The only problem is that none of the bool fields are on the model....

friendly_id / content_url without scope

class Content < ActiveRecord::Base has_friendly_id :title, :use_slug => true end How I can make a link like /about-us instead of /contents/about-us ? Should I modify the content_url method , or is there a better approach ? ...

url_for generates a url with current path inserted

I am generating a url in my controller accessed from the relative path "/hangouts/test", for a url on an external site (facebook). I want to use url_for and pass in params using hashes so it can escape them. The URL I want is this: http://www.facebook.com/connect/prompt_permissions.php?api_key=6aca22e72866c7eaaedfb15be69c4b93&amp;... U...

How to rewrite url using apache for mongrel?

I use mongrel to run a ROR website. My apps need to respond to urls generated by third parties. There is double quote in the url, and mongrel will error on such urls. Since I use apache on top of mongrel. How can I use the mod_rewrite in apache to encode the url? ...

Routes - Tidily define multiple resources with customisation

Hi My routes are getting out of hand due to the fact that this isn't possible (correct me if I'm wrong): map.resources :english_pages, :as => :english, :spanish_pages, :as => :spanish do |article| Due to nested routes things are spiralling out of control (tidiness). map.resources :english_pages, :as => :english, :member => {:manage ...

How to use hudson tracker with a Ruby on Rails project?

I am very new to ruby on rails.. working on my first project... am using Ankh SVN for source control... I want to use Hudson tracker also... I tried it on my own but not able to succeed... i have not used any build files at all... but when i hit build now it fails and when i see the console output it says U test\unit\product_t...

Can we change the way Rails writes HTML IDs and such?

I just started checking out Wordpress' CSS Architecture to study a system that's established and pretty powerful to learn better HTML habits. I've noticed they use all hyphens - (post-554 for example), while Rails uses underscores _ (post_554 for example). I'm wondering if there's some setting to customize this in Rails, something like...

Query with Ruby on Rails

Hi: I'm struggling with a rails query. Finally, I want to make a JSON response with the following contents: A listing of all countries which have at least one company, associated through "Address" and a count of how of how many companies reside in a country. Here is my simple model structure: class Country < ActiveRecord::Base has_...

Multiple tables on one page with prawn

Hey, I'm using prawn for pdf generation and everything works quite well, but now I'm having a bit of a problem. When I put multiple tables on one page, they just get put over each other and not under each other. Is this normal behaviour and what can I do about it? I add the tables on the most normal behaviour btw :) Thanks! ...

Rails3 and Paperclip

Hi, I have migrated my application from rails 2.3 to rails3 and i have a problem with paperclip. I saw there was a branch for rails3 on paperclip git. So I added "gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git', :branch => 'rails3'" into the Gemfile and launch the command bundle install. Once paperclip installed, ...

check if a date is older that the current time in Rails

Hello, I am doing a validations in my model to check if a date is older than today (meaning a date can only be in future from the current time) I was about to write down a block of code, but was wondering is there a build in function for this. The date is passed from a view using: <%= date_select ('load', :valid_until, :order => [:d...

How to specify :primary_key starting value in rails schema migration?

I have a postgres table and a schema that creates a primary id (sequence) that auto increments by 1. How do I specify the starting value? I am happy with the increment value. Here is my schema migration: create_table "ServiceProvider", {:primary_key => :ID} do |t| t.integer "ID", :null => false end Thank you ...

How to read form-data with ruby

Hi, In my controller the result of request.body.read is: ============= --AJAX-----------------------1267183973160 Content-Disposition: form-data; name="1261400603_page_white_word.png"; filename="1261400603_page_white_word.png" Content-Type: application/octet-stream thefile --AJAX-----------------------1267183973160 Content-Disposition...

Reloading controller classes during tests

I have some functionality in a rails app switched on or off with the use of constants, and I'm using these in the controller class definitions, e.g. class SampleController < ApplicationController if ONE def index render :text => '1' end else def index render :text => '2' end end end The constants are ...

active record find from 2 tables in rails

Hello, I have two tables 'users' and 'loads' in the models I have defined that 'loads' belongs to a user and that a user have many loads Now when I want to show details for a load I use this in my controller: @load = Load.find(params[:id]) and then in my view output data like: <%=h @load.user_id %> <%=h @load.date %> . . . What I...

How to save http referer in rails

I'm trying to save the site that a user came from when they sign up. Right now I have a before_filter in my ApplicationController: before_filter :save_referer def save_referer unless is_logged_in? session['referer'] = request.env["HTTP_REFERER"] unless session['referer'] end end Then when a user is created, it chec...

Help with Ruby on Rails 5 points ranking algorithm

Hello fellows - I'm currently in the process of developing a digg-like Ruby on Rails application for my degree's Final Project and I'm stuck in the 5 point ranking algorithm. There are a couple of factors that need to be involved, here's a breakdown : Users They'll have a personal 5 points ranking per category with 5 being the best ...

In a MVC patterned framework where would a screen-scraping module be located?

In a MVC patterned framework where would a screen-scraping module most logically be located? In the model or the controller? Or is it completely outside of this pattern? ...

Rail status codes and XML

Hey... Controller: class CategoriesController < ApplicationController def create @category = Category.create(...) respond_to do |format| if @category.save format.xml { :status => :created } else format.xml { :status => :unprocessable_entity } end end end end View: xml...