ruby-on-rails3

How to install paper_trail plugin on Rails 3

I'm sure this is astonishingly straightforward, and I'm just inexperienced with Rails 3, but I can't figure out how to make it work. I'm trying to install the paper_trail plugin into my Rails 3 app; but the instructions seem designed for Rails 2. I'm running under Windows, and don't have git available. I've tried putting gem 'paper_tra...

Rails: How to chain scope queries with OR instead of AND ?

I'm using Rails3, ActiveRecord Just wondering how can I chain the scopes with OR statements rather than AND. e.g. Person.where(:name => "John").where(:lastname => "Smith") That normally returns name = 'John' AND lastname = 'Smith', but I'd like: name = 'John' OR lastname = 'Smith' ...

Rails3 and Easily caching views and controllers

Hi all, I am currently caching my web application. So I was driving to use memcache and i was looking for an easy way to handle all that. For exemple, i would like to cache all my contents until they are not modified. And I can't cache all the page because some parts need to be cached apart. So I could use a fragment_cache for the c...

Rails 3 does not see my Rack application in "lib" directory

I've placed the file rack_app.rb with simple Rack application in the lib directory: class RackApp def call env [200, {}, 'Hello'] end end Then I've added this route: match 'rack' => RackApp And when I try to launch the rails server I get the following error: config/routes.rb:65: uninitialized constant RackApp (NameError) ...

Best way to access a Rails 3 REST-ful web service using a VB.NET consumer?

What is the best way to access a Rails 3 REST-ful web service, developed using standard Active Resource techniques including HTTP authentication over SSL, from a VB.NET consumer? Consumer can be .NET 4.0 if that is necessary. Are there any .NET libraries yet that can bridge the gap? I have already come across links like this (http://...

ActiveModel and path helpers

In a Rails3 app, I want to use resourceful paths for an ActiveModel EntityImage representing image file uploads. In some directory I have these files dir/#{type}/#{id}/#{size}.jpg (which are basically all important fields of that class) Now, probably, because 'id' is a bad name rails wise (it is not domain wise), when I want to make a d...

How do I implement a 'social' aspect with mongoid

I am attempting to create a friend network on a site I am making. I am using Mongoid. How do I instantiate friends? I assume that Users needs to have a relational association with multiple other users. But the following code: class User include Mongoid::Document references_many :users, :stored_as=>:array, :inverse_of=> :users en...

Association not finding created objects in tests

I have following models in my app: class Game < ActiveRecord::Base has_many :players has_many :villages, :through => :players end class Village < ActiveRecord::Base belongs_to :player end class Player < ActiveRecord::Base belongs_to :game has_many :villages before_create :build_starting_village protected def...

ruby on rails sql statement error

Hi guys i have a model livestream which has two columns in the database, 'user_id' and 'activity_id'. Very straight forward. Now when I try to insert multiple records into the database I get an invalid SQL statement: SQLite3::SQLException: near ",": syntax error: INSERT INTO livestreams (user_id, activity_id) VALUES (1, 2), ...

Rails 3, Modeling Question

Hello, rails 3 newbie, using Devise for auth... I want to create the following models: class Instance < ActiveRecord::Base has_many :users has_many :notes end class User < ActiveRecord::Base belongs_to :instance end class Note < ActiveRecord::Base belongs_to :instance end To create a new note in the notes_controller.rb def cr...

Adding an associated Table to an Existing Table (Book > Revision)

Hello, newbie here... I have the following models: class Instance < ActiveRecord::Base has_many :users has_many :books end class User < ActiveRecord::Base belongs_to :instance end class Book < ActiveRecord::Base belongs_to :instance end I now want to add a BookRevision table, that has the following columns (id, user_i...

Vestal Versions - Rails 3 Support?

Hello, I'm real interested in using Vestal Versions with Rails 3. Does anyone know if Rails 3 works with Vestal Versions? I've heard some users are running into issue: ActiveRecord::DangerousAttributeError: changes is defined by ActiveRecord" It uses a field in the model called changes. Not sure if there are plans to fix that or not. ...

Restoring Rails 3's Bundle Install Path... It's now install in my root

Hi, I did something while trying to install the vestal_versions plug-in that ended up creating a vestal_versions directory in my app's root with the following: - Application - APP - DB - vestal_versions - ruby - 1.8 - bin - cache - doc - gems - specifications Which if deleted prevents the...

Install Mogli Gem on Rails 3

I am trying to install the mogli gem( http://github.com/mmangino/mogli ) on rails 3 and am running into problems with the configuration. I have NO prior experience with Rails 2. For Rails 2 Add config.gem "mogli" to environment.rb For Rails 3, I added the following to the gemfile. gem 'mogli' For Rails 2, routes map.resource :...

Creating a Scope that joins user_id with the User Table (user.id) --- Rails 3

Hello, I'm using Rails 3 with devise. I have a table books which has a column for user_id, which is related to the Users table (user.rb) I'm trying to create a Scope that shows all the books with the user's email address (Books joined to Users) class Note < ActiveRecord::Base scope :personal, proc {|user| where(:user_id => user.id) }...

Rails 3 default datetime format without UTC

Hi all, I'm creating a new Rails 3 app, and in it I use datetime for a couple of fields, however every datetime field standard has UTC behind it (in a view), like: 2010-10-10 16:19:00 UTC How do I get rid of the UTC part? UPDATE: here's what I have so far: <%= trip.truckleft.strftime("%Y-%m-%d %H:%M") %> So all I have to do now...

Vestal Versions -

Hi, I'm using the Vestal Version Fork here for Rails 3 support: http://github.com/adamcooper/vestal_versions/ The issue I'm having is that the updated_by => current_user is not storing in the versions table on update. def update @book = Book.find(params[:id]) respond_to do |format| if @book.update_attributes(params[:...

Something wrong in my sequence of factory creation..

I was hoping someone would spot why this wouldn't work. I am getting an error thats being called because the attributes I specify with Factory_Girl are not being applied to the stub before validation. The Error: undefined method `downcase' for #<Category:0x1056f2f60> RSpec2 it "should vote up" do @mock_vote = Factory.create(:vote...

How I get the Railscasts episode "#229: Polling for Changes" to work with a nested route?

I have a rails 3 application very similar to the one in Railscasts episode #229 the only difference is that in my code Articles is called Posts and I have a nested route: routes.rb: Myapp::Application.routes.draw do resources :posts do resources :comments end root :to => "tags#index" end I receive this error in the terminal...

Problems using Maruku in Rails 3

I am new to Rails but have used PHP extensively over the years. I am building a simple blog (I know) to get my skills up in the MVC/Rails world. I have the basics working but have spent the weekend trying to get Maruku to work eg a post body saved from a text area with Markdown Extra markup to the db and then back again to the browser. ...