ruby-on-rails

Text Messages & Ruby on Rails

Is there any way to use text messages to CRUD data in a Rails app? For instance, a user would send a text message to a specific number and the Rails app could use that data in any way. Just wondering if there's a solution out there. ...

how to export my ruby on rails application data into a zip file with all attachments and yaml files

im trying to backup my ruby on rails instance as a zip file with yaml files and other attachments in a zip folder. How can i do this? ...

How to keep style for HTML in Ruby/Rails?

I'm a beginner to Ruby/Rails, and just generated my first HTML programmatically - kind of exciting-- but when I viewed "page source" from the browser, my HTML had all these additional gaps and messed up the logical indentation: This code in a View: <% @states_array.each do |state| %> <ul><%= state %></ul> <% end %> and this code in...

Ruby on rails activate record condition

Hi, Is there a way to specify and OR condition? For example: Message.find(1, :condition => {"profile_id = ? OR sender_id = ?", 2, 2}) Ultimately, I want to check whether a user has sent or received a message, but if I do them separate I an exception is thrown when the record is not found for one of the cases. ...

" undefined method `enumerable_enumerator_path' " error.

I'm using basic scaffold structure. What I need, is to add 'moderate' action and view by changing published to true. In my idea, on moderate.html I should get the list of all unpublished entries with the ability to change and save their parameters. Here are parts of my code: #names_controller.rb def moderate @name = Name.find(:all, :...

How to get objects of used Rack middleware running in a Rails app

I'm using Rack middleware that accepts some configuration that I need to change at run time. So I need the instance of its class that's currently in memory. Is there a way to do obtain it? ...

An interesting little 500 error

I just tried to deploy to Heroku and got a 500 server error. heroku logs: Started GET "/" for ##.##.###.### at 2010-10-14 17:59:34 -0700 Processing by WelcomeController#index as HTML Rendered welcome/index.html.erb within layouts/index (2.3ms) Completed in 3ms ActionView::Template::Error (can't convert nil into String): 5: <...

Parsing simple XML with Nokogiri

Let's say I have the following XML : <links> <item> <title>Title 1</title> <url>http://www.example.com/url-1&lt;/url&gt; </item> <item> <title>Title 2</title> <url>http://www.example.com/url-2&lt;/url&gt; </item> <item> <title>Title 3</title> <url>http://www.example.com/url-3&lt;/url&gt; </item> </l...

Snow Leopard Terminal begins to execute Ruby installation upon launch

Hello, at some point after I installed Ruby on rails, my terminal on Snow Leopard began executing the configuration (?) procedure for Ruby. Last login: Thu Oct 14 21:39:51 on ttys002 /Users/Adam/.rvm/rubies/ruby-1.9.2-p0, this may take a while depending on your cpu(s)... ruby-1.9.2-p0 - #fetching ruby-1.9.2-p0 - #extracted to /Users/A...

How do I display error messages for nested resource validations?

I'm creating a basic blog application and I'm running into issues displaying error messages when a user tries to submit a blank comment. Instead of getting a nice looking error message, an active record error message with the correct validation erorrs. Such as ActiveRecord::RecordInvalid in CommentsController#create Validation ...

Is it okay to return presenter objects from a presenter when using the "Presenter Pattern"?

For example: class Tree has_many :apples end class Apple belongs_to :tree end class ApplePresenter presents :apple def name @apple.name.upcase end end class TreePresenter presents :tree def apples present_collection @tree.apples end end Using this, there's no need to duplicate the ApplePresenter methods a...

Rails metaprogramming and validations

Given a particular model, is there a way to see and edit existing validations? I'm writing a plugin and I need to modify a validation if it exists. For example: If I have a User model with validate_uniqueness_of :ssn This model is using the plugin so I need to modify that validation and add an :if or a :scope, etc. So basically if ...

Rails resourceful routes all point to index action?!

I'm runnng Rails 2.3.8. I set up map.resources :users in my routes.rb file. When I run rake routes it shows: users GET /users(.:format) {:action=>"index", :controller=>"users"} GET /users(.:format) {:action=>"index", :controller=>"users"} new_user GET /users/new(.:format) {:action=>"in...

Struggling with a complex Rails 3 query (need: user.friends.checkins)

I'm working on a social networking application and am trying to build a complex query that efficiently pulls all of a users' friends' checkins from the database. Basically I need: "user.friends.checkins" I've recreated (in simplified form) the data structure below for reference and included several solutions I've found, however I feel ...

how to valiation embed video in ruby?

please suggest me a gem or way validation embed video by ruby code. Example: Youtube Video, Google Video. ...

Using hidden fields to host foreign key data for a child record?

Does using a hidden fields on a form allow for the possibility of someone spoofing the data in the hidden fields that are posted back? For instance, in my Rials app I have parent-child structure where I call new_project_task(@project) which hits the tasks controller create action, and on the page I do not want to show a field for the f...

How to use rails3 with RedCloth. require 'RedCloth' not working

I have installed RedCloth, by using the devkit. Using gem install RedCloth. If I use plain irb, then require 'RedCloth' works fine. But if I use rails console and do require 'RedCloth', it says it can't find file to load. Please help. Rails 3.0.0 RedCloth 4.2.3 ...

Rails Production server: stylesheets not displaying!

I just switched over from my development database to the production database, and I realized I'm getting a consistent error nomatter what view I try to open. The stylesheets are not loading correctly, despite being in the correct place. Here's some information about the error: View <head> <%= stylesheet_link_tag "global", "home", "htt...

ruby on rails gravatar_image_tag

Hi, I am following the railstutorial.org tutorial. While I am able to see the gravatar on the webpage, my rspec test is failing. Here is the user_controller_spec.rb test: describe "GET 'show'" do before(:each) do @user = Factory(:user) end it "should be successful" do get :show, :id => @user response.should be_suc...

Bundler breaks resourceful routes?

Bundler is breaking my resourceful route! To confirm I created a clean rails app (2.3.4) and made a users scaffold. map.resources :users creates the following: users GET /users(.:format) {:controller=>"users", :action=>"index"} POST /users(.:format) {:controller=>"users", :action...