ruby-on-rails

Catch action parameter in route

I'm making use of hookbox which handles a socket for web. My browser sends information with javascript to hookbox and hookbox forwards the information to my ruby application. The problem is that hookbox sends a parameter called action, so I assume it would look like this. /hookbox/index?action=connect&user=test, when I ask for the para...

Ruby on Rails and MAMP Pro

hey all, new to ruby, and rails... but not to the amp stack. my preferred method for local development has always been to use MAMP Pro for it's ease of use and speed. but, i seem to have some more configuration to do if i want it to work with ROR. i've got my server name setup (rails.dev) to use port 3000 and the disk location is set ...

Missing keyword_end on haml partial template processing

Because I was getting myself annoyed with the HTML tags, I started to convert my project to HAML, since it is a lot better structured. I am glad the installation provides the tool html2haml to help me with it. While being syntactically correct, processing the file gives me a weird error I don't quite get: /stories/_story.html.haml:28: ...

Git workflow on Heroku

Hello! I am a "GIT newbie" as of starting with Heroku, and I'm interested in knowing what would be best practice in how to work with it. As of now my site has one production environment and one staging environment. However I'm only using the most basic GIT commands, i e: git add . git commit -m "some changes" git push production mast...

No route matches on Railstutorial.org

I generated home and contact page thru: rails generate Pages home contact did tests to verify and all was okay, now I wanted to add the page "about". I created the about.html.erb through copying the contact.html.erb and pasting then renaming it to about.html.erb. I then changed the content to "Pages#about" instead of "Pages#contact" ...

How can I do a find in Rails with conditions set on the join table of a :through association?

I have the following models: class User < ActiveRecord::Base has_many :permissions has_many :tasks, :through => :permissions class Task < ActiveRecord::Base has_many :permissions has_many :users, :through => :permissions class Permission < ActiveRecord::Base belongs_to :task belongs_to :user I want to be able to display ...

There has got to be a better way of doing this radio logic

I have this form and a yes or no radio choice. The get_request_ids(song) basically gives me the ids i need. <% form_tag '/somewhere' do -%> <% [ 'yes', 'no' ].each do |status| %> <%= radio_button_tag "group[]#{get_request_ids(song)}", "#{status}[#{get_request_ids(song)}]" %> <%= status.humanize %> <% end %> <tr><td><%= subm...

Defining models with Mongoid for this database structure

Hey I'm trying to build a rails 3 app with Mongoid (for MongoDB). What I'm now trying to do: Languages: id (automatically created, right?) name (e.g. English) code (e.g. en_US) Languages_Texts: id (see above...) name (e.g. hello_world) Translations: id (see above...) translation (e.g. Hello, world!) I hope this database sc...

How do I write a select_year backwards from today's year?

I understand there is a select_Year but i can't figure out how to use it: = f.select_year("dob", :start_year => DateTime.now.year, :end_year => DateTime.now.year - 100 ) This is incorrect..how would you actually write this? My attribute is :dob ...

How do you test an AJAX request with RSpec/RoR?

I'm fairly new to RoR and recently started learning BDD/Rspec for testing my application. I've been looking for a way to spec an AJAX request, but so far I haven't found much documentation on this at all. Anyone know how to do this? I'm using rails 2.3.8, rspec 1.3.0 and mocha 0.9.8 for my stubs (which I'm also in the process of le...

Is it wise decision to move from .NET to JEE or RoR?

To develop a new project we are thinking to train .NET people learning either JEE or Ruby on Rails. This decision is just because of open source and to avoid purchasing of operating system also Sql Server database. Currently there are no people who work on either JEE or RoR. All team members should learn from the scratch. If applicati...

sproutcore & rails: where does the sproutcore application live within rails' directory structure?

I have a working Rails 3 app service plain old HTML CRUD and I want to build a sproutcore client for the same. I (think) I understand Rails and Sproutcore, but I have an embarrassingly silly newbie question: Where do I put the sproutcore app within the rails project structure? Specifically, given that I have: myapp/ app/ ... ...

Verifying page title with rspec

I'm running through Michael Hartl's Rails Tutorial. I'm trying to verify the title of my page. The test looks like this: it "should have the right title" do get 'home' response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Home") end The HTML head section looks like this <head> <...

Can’t dup NilClass when creating a child model using Single Table Inheritance

Possible Duplicate: Rails - Cannot dup NilClass when using Single Table Inheritance Hi guys, I'm using Rails 2.3.8 and Ruby 1.8.7 under Windows (yes I know I should be using linux... don't have time to do that now =P) I'm trying to make a simple STI model. Where I have a class User and 1 subclass (BusinessContact) inheritin...

how to add gem dependency with :path and :branch

I am working on a rails gem that has dependency on the following gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3' How can I add this in the gem spec as a dependency? Specifically I need to specifiy the path and branch in the dependency. ...

Rails Giving Each User Their Own Customizable Stylesheet

Hello, This is a fairly straightforward question. I have Users in my Rails3 Application. I want to give each user the ability to customize their stylesheet through a form so they can essentially have their own themes. I was wondering how I can go about getting this to happen and what is the best way that you have seen it done? Wou...

Send HTML emails with inline images with ActionMailer

Hi I have a simple ActionMailer class like this: class MyMailer < ActionMailer::Base def mail(from, to, cc, bcc, subject, message, sent_at = Time.now) @subject = subject @recipients = to @from = from @cc = cc @bcc = bcc @sent_on = sent_at @body["message"] = message @headers = {} end end And I ue it ...

Should I test controller helpers or the controller itself with Rspec?

I have a PathsHelper that overwrites foo_url and foo_path by processing additional parameters as well as the context from the current url. This is included in ApplicationController. Right now, I have: describe ApplicationController do describe "#foo_url" do ... end describe "#foo_path" do ... end end I'm wondering w...

A/B testing strategies & gems for ruby on rails

Hi, I'd like to do A/B testing for my views and I was wondering what gems are out there and what strategies you can suggest. I already found http://www.bingocardcreator.com/abingo but I can't tell if that does entire templates as well, or just buttons, etc. suggestions? ...

How does ASP.NET MVC 2 handle different request formats (i.e. HTML, XML, JSON, JS, etc.)

Hello. I'm diving into ASP.NET MVC 2 and I'm trying to understand how it handles different request formats. In Ruby on Rails, you specify in the controller which response format to return based on the request... respond_to do |format| format.html #action.html.erb format.xml { render :xml => @employees.to_xml(:root => "employees") ...