I'm doing my first Ruby on Rails project. I am working on a project where the user can add a new message. Then they can add updates to this message like a thread. I've got it all written and now I'm going back and applying some AJAX. I want to show just the main message when the page first loads. Then when I click a link I want an A...
I have a Rails 2.3.x app that implements the act_as_authentic in User model and a UserSession model as per Authlogic Github example. I am implementing an API to allow access from iPhone. Will be using HTTP Basic authentication via https (will not implement single access token). Each API call requires a username/password for the access.
...
Can someone point me to a solid sample app that shows how to use the new features and syntax of Rails 3?
It's been answered before for earlier versions (http://stackoverflow.com/questions/248371/whats-the-best-open-source-ruby-on-rails-project-to-learn-from), but I have not seen one for Rails 3.
Specifically the following:
Routing
Ma...
When I execute a Rails unit test from the command line (as suggested here) such as
ruby unit/test_model.rb
...I get this error:
No such file or directory - .../test/config/database.yml (Errno::ENOENT)
Am I doing something wrong? Or is there a workaround?
...
So, we have an existing Rails 2.3.5 app that does not support Internationalization at all. Now, I'm well familiar with Rails I8n stuff, but we have a LOT of output strings inside /javascripts/. I'm not a huge fan of this approach, but unfortunately it is too late to fix it now.
How might we internationalize strings stored in JS files in...
Hi, I'm new to rails, and have taken some existing site for new enhancements. I mirrored rails application from remote server, and running locally using "ruby script/server" server.
The problem is any changes to the files are not being reflected in web browser. Is this because of caching somehwere. Can someone pls point me where should ...
I have a "restaurants" table with a "name" column. I've defined the following index:
indexes "REPLACE(UPPER(restaurants.name), 'THE ', '')", :as => :restaurant_name, :sortable => true
... because I want to sort the restaurant names without respect to the prefix "The ".
My problem is that whenever one of these records is updated (in ...
I am trying to assign a message to flash[:notice] in a model observer.
This question has already been asked: Ruby on Rails: Observers and flash[:notice] messages?
However, I get the following error message when I try to access it in my model:
undefined local variable or method `flash' for #<ModelObserver:0x2c1742c>
Here is my code:
...
I am looking for TDD resources that are specific to Rails.
I've seen the Rails Guide: The Basics of Creating a Rails Plugin which really spurred my interest in the topic.
I have the Agile Development with Rails book and I see there's some testing-related information there. However, it seems like the author takes you through the steps o...
How would I correctly call the create action from a link_to? I'm using REST (map.resources :recipes). Here's the create action:
def create
recipe = Recipe.create(:name => "French fries")
redirect_to recipe
end
For example, I thought something like this might work:
<%= link_to "Create a default recipe", recipe_path, :method => :po...
I have a form with the following:
<% form_remote_tag :url => {:action => :wotsit} do %>
<%= submit_tag "Foo" %>
<%= submit_tag "Bah" %>
<% end %>
I would expect that the submitted parameters would reflect which button had been clicked. However, no matter which button I click, the submitted parameters include "commit"=>"Foo".
Wha...
Ok so got through my last problem with the difference between Postgresql and SQLite and seems like Heroku is telling me I have another one. I am new to ruby and rails so a lot of this stuff I can't decipher at first. Looking for a little direction here. The error message and PostsController Index are below. I checked my routes.rb file an...
Would anyone be kind enough to dissect the merge! method? Its usage of conditions and variable assignment looks rather terse, and I'm having a difficult time following it. Would love to hear a Ruby-savvy developer break this apart.
module ActiveRecord
class Errors
def merge!(errors, options={})
fields_to_merge = if only=op...
I have an array of ActiveRecord objects, each one which has its own respective errors array. I want to flatten it all out and get only the unique values into one array. So the top level array might look like:
foo0 = Foo.new
foo1 = Foo.new
foo2 = Foo.new
foo3 = Foo.new
arr = [foo0, foo1, foo2, foo3]
Each one of those objects could pot...
getting error:
ActiveRecord::StatementInvalid (PGError: ERROR: argument of HAVING must be type boolean, not type timestamp without time zone
controller code snippet:
def inactive
@number_days = params[:days].to_i || 90
@clients = Client.find(:all,
:include => :appointments,
:conditions => ["clients.user_id = ? A...
My database has a datetime field, and I want to be able to create new entries. Obviously the Rails datetime_select helper isn't the most user friendly thing to have in your form.
I'd rather have a text field for the datetime (or one for the date, and one for the time) and interpret the inputs like PHP strtotime can.
I might just be sea...
class AddTitleToPosts < ActiveRecord::Migration
def self.up
add_column :posts, :title, :string
Post.find(:all).each do |post|
post.update(:title => post.name.upcase)
end
end
def self.down
end
end
Like you can nothing particularly complicated, just trying to add new column title by changing case of name column already...
G'day guys, I'm having an issue with filtering the presentation of several thousand trade items I have in my system. As per the specs of the system we're building we have to have a form that allows people to put in a start date and then an interval in minutes, to filter the presentation of the items. I've built my helper functions to ret...
I have written my basic models and defined their associations as well as the migrations to create the associated tables.
EDIT - Adding emphasis to what I specifically want to test.
I want to be able to test:
The associations are configured as intended
The table structures support the associations properly
I've written FG factorie...
As an ASP.NET developer, I'm used to working with how VS/C# transparently autogens proxy classes for web references via wsdl.exe (yes, I know, we're spoiled), but now that I'm creating documentation for more than one coding platform I'm trying to discover what the equivelant to that is in any other framework.
So is there a similar way ...