ruby-on-rails3

Tracing down routing errors in Rails

I am going through my first RoR tutorial and came up on an action controller routing error. I have checked my code at least 8 times, but can't figure out the issue. I'm sure this will happen again in the future. My question is, in general, how should I go about solving these errors? If it's relevant I am using RVM, Rails 3.0.1 and Ru...

Using the "pg" gem with Rails 3 ... why am I getting this error in Netbeans when I do a "bundle install"???

At my wits end with this! My current set up is: - Ruby 1.9.2 - Rails 3.0.1 - pg (0.9.0) My $PATH right now looks like this: /Users/fjones/.rvm/gems/ruby-1.9.2-p0/bin:/Users/fjones/.rvm/gems/ruby-1.9.2-p0@global/bin:/Users/fjones/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/fjones/.rvm/bin:ARCHFLAGS=-arch x86_64:/opt/local/bin:/opt/local...

How to access joined table attributes in Rails3 ?

I am having trouble accessing the attributes of a join in Rails3. There is two models/tables : Place and Address. One place can have many addresses (i.e. a specific street address, a "corner of" address, etc.). For historical reasons, the tables do not follow standard Rails conventions: class Place < ActiveRecord::Base set_table_name ...

RoR: Creating an Object with string primary_key (associated error: Couldn't find Object_Id with ID=0)

I created a model that had a string primary_key. The Create action in Ruby on Rails gave me the following error: Couldn't find Theme with ID=0 My Theme table has no ID column, but a string column called name which is the primary key. After searching everywhere, I experimented myself with the Create action inside the theme_controller....

Getting Rails 3 working with minimum hassle on Windows 7?

I am looking at a few different ways to get Rails 3 working (database is not important right now) on Windows 7, would appreciate some advice on different stacks and IDEs. I do want to go with an IDE for several reasons such as code completion and because i will be using the ruby debugger (which i find easier to use on a GUI) Netbeans fo...

Rails 2.3.8 with thin doesn't work after installing rails 3.0.1

Hello, I have several Rails applications with version 2.3.8, which I run using the thin server. I want to install Rails 3.0.1 on the same machine for testing purposes. The installation worked fine, but after installing Rails 3.0.1, running Rails 2.3.8 applications with thin fails with this error: >> Using rails adapter Missing the Rai...

Copy fixed data into model

Hi all, I'm developing an application in which a Course belongs to a user. I would like to predefine a number of courses, such that a Course's template details are then copied into the users course details. From this initial point each user has a one-to-one mapping with a course. I'd like to know the best place for the static attribut...

Clean up task when combining multiple tasks in Rake

I have a build task in rake defined with the following dependencies: desc 'Builds the App' task :rebuild_dev => ["solr:start", "db:drop", "db:create", "db:migrate", "spec", "solr:stop"] The first task "solr:start" starts the Solr Indexing server. Now, if the build fails (may be in spec tests fail), the "solr:stop" task is not executed...

Authlogic, rails3_acts_as_paranoid and validates_uniqueness_of :login + default_scope(:conditions => {:active => true})

I want to be able to create multiple user accounts with the same login (because of the case a user deletes his account... and then sign up with the same login). I am using authlogic and rails3_acts_as_paranoid. But there is a problem: Authlogic validates the uniqueness of the login field - and IGNORES the default_scope(:conditions => {:...

Changing the version or rails that my application is using

I just installed rails 3.0.1, when I try to do something like rails server i get the error message below. note the first line saying it couldn't find rails gem 3.0.0.rc: Could not find gem 'rails (= 3.0.0.rc, runtime)' in any of the gem s ources. (Bundler::GemNotFound) How can I make my rails3 app use rails 3.0.1? Thanks, -p.s. the f...

Rails 3 - controller Conditional?

Hello, tricky problem. I have a controller that is: def create . . @project = Project.find(params[:project] @Log = Logs.create(params[:action]).merge(:project_id => @project.id)) ... end The issue hereis that sometimes when DEF CREATE, I'll have a project and I want to record that. Other times I won't and that's perfectly fine, I st...

How to test link_to_unless_current in RSpec view example group

I'm learning RSpec 2 with Rails 3 and while it's been going along quite nicely so far, I'm having a problem testing the helper link_to_unless_current in a view. What I've been trying to do is use a simple assert_select from a view spec to determine if a link is being generated in the following partial view (HAML): %article.post{ :id => ...

Rails wizard like form using jQuery

Hi, I want to build a wizard like multi-step input form for my model. I want to stick to rest practices as long as possible. The individual steps in the wizard don't have much inter-dependency so to avoid the round trip to the server, I want to store the whole data on client side using JQueryUI tabs or similar. I have following ques...

CodeRay and RedCloth in a Rails 3 application

I'm trying to add CodeRay and RedCloth to a Rails 3 application and am getting some strange behaviors. I followed this RailsCast, but since Rails 3 escapes the HTML by default, my HTML is being escaped a couple of times. What do I need to change? module ApplicationHelper def coderay(text) text.gsub(/\<code( lang="(.+?)")?\>(.+?)\<...

Rails 3 - Suggests on a model for Photos

Hello, I'm looking for suggestions on creating a model/scaffold for Photos I want a user to be able to create a album that contains 1 or more photos. Current idea: album id, name, user_id photos id, name, album_id Thoughts? Thanks ...

Rails 3 - AJAX Redirect? Pass class from Controller to View for AJAX

Hello, Here's what I'm trying to do... Controller def create . . if @project.save format.js { @project } end end View window.location = "<%= redirect_to(@project, :notice => 'Project was successfully created.') %>"; In Sum,using AJAX to create a project. When the create is done, I want to redirect the user to the project.....

Using kramdown in Rails 3

I'm trying to add some Markdown styling to my Rails 3 blog application. This should be something simple, but I can't get it to work. I have kramdown in my Gemfile: gem 'kramdown' I ran bundle install. I have an application helper called kramdown module ApplicationHelper def kramdown(text) require 'kramdown' return Kramdown...

Rails - Creating a Landing Page, which is different than the Web App

Hello, I'm rails I've been building a web app. But the web app is completely different than what the landing page (sign in, register, about, etc should look like) How do rails developers handle this? Different layouts? Different CSS files? etc.. what's cleanest? Thanks ...

Rails 3, using Prototype and JQuery, remote => true not working

I have a Rails 3 application that needs to use both Prototype and JQuery libraries. Now I am having problems when it comes to making different kinds of remote calls. I am able to do a remote_function call and return RJS and that works just fine. But, on another page I want to do a form_for :remote => true, but that fails - it just sub...

Is the new Ruby hash syntax not "stylish" within the Rails community?

I am new to the Rails community, and I also like to try and follow the conventions that the community uses. In the Rails 3 books I have been reading I have noticed that the authors have been opting for the old :key => value syntax versus the new Ruby 1.9 style key: value. Do Rails developers generally adhere to one style and not use the ...