ruby-on-rails

Trouble with custom validation of Rails app

I'm making a web app where the point is to change a given word by one letter. For example, if I make a post by selecting the word: "best," then the first reply could be "rest," while the one after that should be "rent," "sent", etc. So, the word a user enters must have changed by one letter from the last submitted word. It would be const...

git clone heroku ssh permission denied..

I just bought a new computer and I am trying to clone my heroku project on it. Here's what I've done so far. I didn't include the trace, but everything was saved in the right place, and the functions ran without errors. >> sudo ssh-keygen >> heroku keys:add >> sudo git clone -o heroku [email protected]:myapp.git Initialized empty Git rep...

Setting up Rails for the first time - is this normal?

I am trying to setup a Rails environment via CPanel. I've tried on several distinct hosting environments (on all of which I used CPanel to create the project) and I always get the following: Is this something I've done wrong - I have to first create models/controllers etc - or something I need to bark up my hosting provider's tree abo...

Undefined local variable or method `_setup_mocks' in cucumber 0.8.5 and rspec2

Inside of : features/support/env.rb require 'cucumber/rspec/doubles' I just ported my project to a new cpu and it's returning this error on everything: undefined local variable or method `_setup_mocks' I'm guessing I'm missing something. Gems : rspec (2.0.0.beta.18) rspec-core (2.0.0.beta.18) rspec-expectations (2.0.0.beta.18) rs...

How to execute a command on the server with Capistrano?

I have a very simple task called update_feeds: desc "Update feeds" task :update_feeds do run "cd #{release_path}" run "script/console production" run "FeedEntry.update_all" end Whenever I try to run this task, I get the following message: [out :: mysite.com] sh: script/console: No such file or directory I figured it's because...

Gem that allows for data access using sharded mysql databases while maintaining the usage of Activerecord

This is a relatively complex problem that I am thinking of, so please suggest edits or comment on parts where you are not clear about. I will update and iterate based on your comments I am thinking of a developing a rails gem that simplifies the usage of sharded tables, even when most of your data is stored in relational databases. I be...

can someone explain to me what respond_to does? (Rails)

So when one generates scaffodl, the controller automatically creates these blocks(?) like this respond_to do |format| format.html format.xml { render :xml => @c } end what does this really do and how come it has format.html and format.xml? What does each do? ...

Reusing Rails' param parsing to turn a one dimensional hash into a multideminonal one based on the key values and array notation

I am currently using rturk which give me back my answers in a one dimensional hash as such... {"answers[125][rating]"=>"5", "answers[126][rating]"=>"5", "commit"=>"Take Survey", "answers[125][rating]"=>"5", "authenticity_token"=>"je0Hx48qKmCzy1zmXCpijYWbl4w92eDMRajWJcVYxe0=", "gender"=>"m", "answers[120][rating]"=>"5", "answers[121][rat...

Where to put model search logic in a Rails application?

I'm trying to figure out the "best" place to put multi-attribute search form logic in a Rails application. The search form in question has several attributes which may or may not have values, and the data types differ between attributes. (For example, there are search options to search for items with a price attribute between two numbers...

looping and casting problem in rails

I've got following method in User model def get_employees @employees = [] groups.each do |i| @employees << Group.find(i).employees end @employees end This is what the console prints when I call this method: > >> User.find(4).get_employees > => [[#<Employee id: 4, first_name: "test", last_name: "tes...

How do I redirect back to the action that the action was called from?

I could pass in a params[:action_callback], but wondering if there is a more elegant way to approach this? 1) I called /submit_posting from the /network page 2) After submit_posting does their magic, i want to do a redirect back to /network ...

Should stopping Webrick also kill the ruby process?

I'm running a rails app with webrick. When I stop the server with Cntrl-C, I still then have to quit and restart Terminal before I can restart the server b/c the Ruby process is still running. Is there a way to get around this? I get: [2010-08-29 00:00:27] INFO WEBrick 1.3.1 [2010-08-29 00:00:27] INFO ruby 1.9.2 (2010-08-18) [x86_64-d...

How to redirect a user after registration when using Devise?

Hi, I am using Rails 2.3 and Devise to handle user registration / authentication. I need to redirect a user to an external 3rd party website immediately after a user signs up for an account. Been looking in the code & online but cannot see how to do this. How can I alter the devise flow to redirect the user? Thanks! ...

Rails 3 RSpec 2 NetBeans integration

NetBeans 6.9 provides a custom Runner class for RSpec to be integrated into the IDE. I'm trying to get my Rails 3 applications specs to be correctly displayed inside NetBeans, but RSpec 2 seems no longer to support custom Runner classes in general. Any ideas how to get the specs into the IDE anyway? ...

Nested models throws Undefined Method Error

I've been following RailsCast 197 to try this nested models/forms and have cracked my head over this code for over 2 hours, but to no avail. What am I overlooking? I have the following Models: class Workout < ActiveRecord::Base belongs_to :user has_many :performed_exercises, :dependent => :destroy accepts_nested_attributes_for :...

Set RAILS_ENV for Custom Test Environment

I have created a custom Rails integration environment that i use to run Selenium tests. The tests run fine in this new environment, however the problem is that within the test code, the RAILS_ENV variable is set to test. I have a test helper class which is similar to the default rails test_helper class, and defines ENV["RAILS_ENV"] = "...

which applications made with Ruby?

hi Can I make a windows application with Ruby? what famous software made with Ruby (on or off the rails :D)? everybody seems to be talking about Ruby , and I need a motivation to learn it. ...

Rails partial overloaded with logic needs refactor

How would you refactor this logic filled partial? <%- for post in @posts -%> <div class="post"> <%= link_to post.title, post %> <%- if post.name.empty? -%> <%- else -%> <span class="name"> by <%- if post.email.blank? -%> <%= post.name %> <%- else -%> <a href="mailto:<...

Merge two ActiveRecord arrays and order by created_at

books = Book.find(:all) articles = Articles.find(:all) By reading from http://guides.rubyonrails.org/layouts_and_rendering.html I knew that I could do something like: <%= render :partial => [customer1, employee1, customer2, employee2] %> and it would use _customer and _employee partials as appropriate. So I want to do something lik...

Comparing one array against another in rails

Hi, I am using the 'contacts' gem in rails to retrieve a users contacts from their mail application. It returns the contacts like so: ["person name", "[email protected]"], ["person name", "[email protected]"], ["person name", "[email protected]"] etc... I want to compare this list to the Users already signed up for...