ruby-on-rails

ActiveModel based class does not create the same results as an ActiveRecord equivilent

Hi, I am developing a Rails 3 app in a largely tabless capacity. I am using savon_model and ActiveModel to generate similar behaviour to ActiveRecord equivalents. Below is my code: class TestClass include Savon::Model include ActiveModel::Validations # Configuration endpoint "http://localhost:8080/app/TestService" namespac...

rails 3 best approach multiple apps within one app

I have a rails 3 app that has 2 different UIs that both share the same model but have different UIs. Lets call these retailers and customers "sites". What is the best approach in rails 3 for creating a monolithic application to keep these two apps in one app. Should I just namespace the controllers, and change routing as such? namesp...

Rails - Find or Create based on TimeStamp? possible?

Hello, In my controller I'd like to do something like the following: @book = Book.find(:all, :conditions = > [" created_at > with in the last 1 minute "] if @book.nil? # Just incase we didn't create a book, we'll initialize one @book = Book.create() end @chapters = @book.chapters.build etc............. * In sum, when the user i...

.gsub erroring with non-regular character 194

I've seen this posted a couple of times but none of the solutions seem to work for me so far... I'm trying to remove a spurious  character from a string... e.g. "myÂstring here Â$100" should be "my string here $100" I've tried string.gsub(/\194/,'') string.gsub(194.chr,'') string.delete 194.chr All of these still leave the  in...

Should RoR urls look like /users/register or /user/register?

Should urls have pluralized words in them or singular? I personally like: /user/register Is this against the 'convention'? ...

Why isn't my 'join' action working, it says the action 'show' can't be found

In my UserController I have: def join end I have a join.html.erb in my /views/user/ folder. My routes has a : resources :user When I go to: http://localhost:3000/user/join I get: The action 'show' could not be found for UserController ...

How do I upgrade from Rails 2.3.5 to Rails 2.3.8?

I've got a Rails 2.3.5 app that I want to upgrade to Rails 3. In the Rails 3 upgrade Railscast, they suggest upgrading to 2.3.8 before going to 3. I've tried Googling but the information I find is all about upgrading to Rails 3. I found this question, which seems to suggest doing gem update rails and rake rails:update, but wouldn't these...

I want the following urls pattern, please help I'm using rails 3

I want the following urls for my UserController: localhost/user/join localhost/user/login localhost/user/user_name (this can be any name in here, it should fire the 'profile' action) Then within the /user/user_name_here/ folder I want: /user/user_name/blah1/ /user/user_name/blah2/ /user/user_name/blah3/ It seems doing resources :us...

Amazon S3 path or to_file wont work

Hey guys ive got the following code in my Model require 'RMagick' class Upload < ActiveRecord::Base belongs_to :card has_attached_file :photo, :styles => { :thumb => ["100x100", :jpg], :pagesize => ["500x400", :jpg], }, :storage => :s3, ...

Does OmniAuth provide simple hooks to the Facebook Graph API?

I am working on integrating Omniauth with my new Facebook application, and I am looking through the rather sparse documentation to understand if it gives simple ways to access the graph API... I am moving from Koala which was pretty simple. Has anyone out there used Omniauth for this yet? I want to get photos from the users' albums, ...

Rails 3 can't find route to static page

Am working my way thru Ruby on Rails Tutorial: Learn Rails by Example. I'm in the section entitled Mostly Static Pages. I get an error after I create an HTML page in the public directory which is called public/hello.html and should appear as in Figure 3.3. My problem is that when I try to create the page and make it appear at localhost:...

Cucumber: Before hook run only once for all scenarios

I have a scenario outline with multiple scenarios. I'd like my Before hook to run only once so I can bootstrap the ActiveRecord objects I need to run against all of the scenarios. The problem is if I use Before do # my code here end This will execute before each Scenario. Is there anyway to run it once for the entire Outline? ...

Rails : get all field for an object coming from the database

Let's say I have an Foo ActiveRecord model with fields foo_id, foo_name and foo_description. After doing something like @foo = Foo.find(1), is there any method "model_fields" such that : @foo.model_fields() would return the array ["foo_id", "foo_name", "foo_description"] ? Thanks for the help, Nicolas. ...

Rails: strange behaviour with trailing slashes on my scoped routes

The locale switching on my site is behaving strangely. I decided to go with a scoped route for switching locales: scope ":locale" do devise_for :accounts resources :eventos root :to => "eventos#index" match '/sign_in' => "Devise::Sessions#new", :as => :sign_in, :constraints => { :method => "get" } match 'sign_in' => "Devise...

How can I install different versions of Rails and keep the existing ones?

I had Rails 2.3.5 installed, and wanted to upgrade to 2.3.10 as a stepping stone to Rails 3. I thought running gem install rails -v=2.3.10 would install 2.3.10 and keep 2.3.5 as well. But now when I do Rails -v, it only lists Rails 2.3.10. How can I install different versions of Rails and keep the existing ones? ...

Rails: routing update error

I am getting a routing error: No route matches "/deccom_tasks/update/1" with {:method=>:put} I'm not sure why I am getting a routing error for a route that usually works. Route: map.resources :decom_tasks, :collection => {:sort => :post, :deactivate_task => :get, :reactivate_task => :get} Controller: def update @task = Task....

How can I submit a value from another field on the page via link_to with Rails?

Here is what I want to do: <%= link_to "Approve", brand_user_brand_roles_path(@brand), :with => "forms[0]['user_brand_role_role_id'].value", :method => "POST", :remote => true %> I know that this doesn't work. I want to call a controller method remotely, including as a parameter a value that is selected in a field other than what ...

Integrating iPad/iPhone App with Rails Application

Hi all, I'm a student working on a project where a need to integrate my iPad (or iPhone) application with a Rails Web App, populating the database from the iOS side and displaying the contents in the web app. I've found ObjectiveResource, but I've had difficulty getting it up and running (went through the getting started, and had the si...

If my "Then I should see" Cucumber feature is failing, how can I see what Cucumber is seeing?

Presumably if Cucumber is not seeing what I expect it to see, it must be seeing something else. Mirroring in my application what I think the same steps are, I get the desired output. This is a "signing in" feature. It appears that sign in is failing in the test. But unless I can see the error message, I don't know why it's failing! ...

Autotest - Load Error - Error posted

bundle exec /Users/new2/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -S /Users/new2/.rvm/gems/ruby-1.9.2-p0@rails3tut/gems/rspec-core-2.0.1/bin/rspec --autotest '/Users/new2/work/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb' /Users/new2/.rvm/gems/ruby-1.9.2-p0@rails3tut/gems/rspec-core-2.0.1/lib/rspec/core/configuration....