ruby-on-rails

Rails3: warning: toplevel constant ApplicationController referenced by ...

Everytime i get a warning: app/controllers/agency/agencies_controller.rb:1: warning: toplevel constant ApplicationController referenced by Agency::ApplicationController My agencies_controller.rb: class Agency::AgenciesController < Agency::ApplicationController def index ... end ... end And Agency::ApplicationController...

Serving XHTML as application/xhtml+xml with Ruby on Rails

I'm trying to get my Rails app to serve XHTML content properly, with the correct content-type of application/xhtml+xml. Ideally with content negotiation so that IE users get a chance to use the site too. Given that all the HTML generated by Rails is marked at XHTML 1.0 Transitional, I'm a bit surprised that there is no obvious option to...

RoR: How to print all elements that belongs_to this table

Ok, I'm not sure that my title was clear enough, but I will try to explain I have two tables: orders that has_many items and items that belongs_to orders. I just started to learn RoR and stuck with a simple task. All I want is to display orders and related items like this: Order 1: Item 1 Item 2 Order 2: Item 1 Item 2 ... I k...

Asp.net MasterPage equivalent in Ruby on Rails, Trying to define a site wide layout.

Asp.net WebForms and MVC has a concept of Masterpages which make it easy to define a one time layout for all the page of your site. In Rails I'm struggling to find an equivalent usage pattern or feature. From what I've read it's really easy to define a layout in every action with: layout: 'viewname' Now that seemed pretty ceremonial...

Rspec2: undefined method 'post'

I'm having trouble runnng rspec2 and rails. Here's my log: 1) TrackController home path should be /track Failure/Error: Unable to find C to read failed line undefined method `route_for' for #<#<Class:01x5ffe7c2f>:0x77d36efb> # ./spec/controllers/track_controller_spec.rb:5 # :1 Here's my spec: describe UsersController,...

Rails routes and site performance

Is there a direct correlation on site speed with the number of namespaces / routes in the routes.rb file of a Rails Application? I am handling a fairly large application with more than 30 disparate models/entities and most of these resources have their own routes. ...

To code background process in Ruby or C++ for rails app?

I've been working on a rails app for a couple of days now that I need an underlying "middle layer" for that connects my rails application to the various services that make up the data. The basic setup looks like this: Frontend ("Rails app") -> user requests data to be aggregated -> info goes in database and a JSON request is sent to "...

Bundler not working: in `[]': undefined method `[]' for false:FalseClass

Hi, I'm having some troubles with my Rails app after installing (and removing) Compass. bundle install gives me the following: /Users/[..]/.rvm/gems/ruby-1.9.2-head@rails3beta/gems/bundler 1.0.0.beta.2/lib/bundler/settings.rb:10:in `[]': undefined method `[]' for false:FalseClass (NoMethodError) from /Users/[..]/.rvm/gems/ruby-1.9.2-he...

problems with cookies

i'm using restful-authentication plugin with rails 2.3.8 i've problems with cookies store i've put a logger instruction in this function for check the cookie: def send_remember_cookie! cookies[:auth_token] = { :value => @current_user.remember_token, :expires => @current_user.remember_token_expires_at } ...

Authlogic and RSpec, errors only running all examples

I have a Profiles Controller that acts_as_authentic with AuthLogic and I am trying to test this action: class ProfilesController < ApplicationController before_filter :require_user, :except => ['new', 'create'] def index redirect_to(current_user) end end The following example is in a spec file with 18 other pending examples...

Could not find activerecord-jdbcmysql-adapter (existing is for Java)

I've been struggling with this problem for a few hours and it is preventing me from even starting my server, which therefore is stopping development completely. I am running Windows, Bitnami Rubystack, and that's pretty much it. I downloaded and installed NetBeans yesterday but my primary editor is Notepad++. I am not using JRuby. Here...

Rails single table inheritance and subclasses name problem

Hi, all. I have 3 classes: class User < ActiveRecord::Base has_many :events, :foreign_key => 'owner_id' end class Event < ActiveRecord::Base belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id' end class Event::User < Event end Class Event have 'type' field, and work as STI. Now i create Event: Event::User.cre...

Rails 2.3.5 and inconsistent JSON/XML ActiveRecord serialization

I'm finding that XML and JSON serialization in Rails 2.3.5 don't seem to work the same. Has anyone encountered this and come up with a workaround? class Record < ActiveRecord::Base ... def my_method { :attribute1 => 'value1', :attribute2 => 'value2' } end ... end @record.to_json(:method => [:my_method]) returns correct JSON...

Writing out a custom file as a response from a rails controller action

So I want to dynamically generate a MIDI file on a web request.Coming from the Java world, I expected something to the tune of class MidisController < ApplicationController before_filter :set_content_type def set_content_type @headers["Content-Type"] = "audio/midi; charset=utf-8" end def show midi_data = get_midi_da...

Even Spaced Primary / Secondary Columns in Rails

I have a set of regions and cities (nested) and want to be able to output them in a few even length columns ordered alphabetically. For example: [Alberta] [Ontario] [Quebec] Calgary Hamilton Hull Edmonton Kitchener Laval [Manitoba] Ottawa Montreal Winnipeg Toronto Waterloo I took a look at 'in_gr...

ActiveRecord::Base.connection.execute duplicates sql output

I am a newbie to rails and i needed to execute some sql query and output it to the view. In my controller i used something like "@prob = ActiveRecord::Base.connection.execute("...") and then simply displayed the @prob in the view. However the output in the view keeps coming twice as 0 result column name result . The sql query was @cp...

Prevent images from downloading with ScrAPI

I need to scrape some websites, and would like to avoid downloading images from the pages I am scraping - I only need the text. I am hoping this will speed up the process. Any ideas on how to manage this? Thanks, Jon ...

How do i go about searching in Ruby on Rails?

I would like to implement a simple search. Let's say the user enters 'york', then I would like to find all records that has a matching substring like 'new york' or 'yorkshire'. So far I have figured out I will have to use the find method, but I can't figure out how to match for substrings. ...

adding value of input box to URL as a param after a button is pressed?

Hi I have one input field and 2 buttons, each button performs a different function. i want one of the buttons to take the value of the input field and add it to a specified Url (as a param) that button should go to. so if the value inserted in to the box is "dog" then after clicking the button the URL should be "/go_somwhere?value=dog"...

Relationships of model

Hi! How can I get all relationships for model. IE, I've got User model: class User < AR::Base has_many :messages, :foreign_key => 'author' has_many :posts belongs_to :role end So how can I know which relationships User model has got? And foreign_keys if they are presented. ...