I'm attempting to use rspec in a rails project I've just upgraded to rails 2.3.2. I've installed rspec 1.2.6 and rspec-rails 1.2.6 as plugins in the app.
My problem is the specs don't have access to my app classes or any of the rails standard libraries.
First I had to specify the model class I want to test by using the full path from R...
I was reading Simply Rails by Patrick Lenz... maybe I missed something, it seems that whenever we put
map.resources :stories
in routes.rb
then immediately, the controller will have special convention and now Story is a RESTful resource? Maybe the author used the word resource but didn't mention that it is RESTful but they are the sa...
It seems that when we use
form_for @story do |f|
then Story has to be a RESTful resource and it has to be
map.resources :stories
in the routes.rb.
Can Story be not RESTful? Can it be a form for non-RESTful data?
...
My apologies if this has been answered before or is obvious...did some searching here and on the Goog and couldn't find an answer.
I'm looking to sort an array of Providers by price and whether they are a preferred_provider? (true or false)
For instance in array p of Providers...
p1.price == 1, p1.preferred_provider? == false
p2.price...
I have a RoR application that's using the RESTful Authentication plug-in. Everything works great. I recently enabled cookie based authentication and that works fine too. The problem is that I want to change the default landing page when the user is authenticated using a cookie. I want to have a cookie authenticated user redirected to ...
new_story GET /story/new(.:format) {:action=>"new", :controller=>"stories"}
edit_story GET /story/edit(.:format) {:action=>"edit", :controller=>"stories"}
story GET /story(.:format) {:action=>"show", :controller=>"stories"}
PUT /story(.:format) {:action=>"update", :controller=>"stories"}
...
I'm currently learning Ruby and RoR and I stumbled across this declaration:
link_to_remote(name, options = {}, html_options = nil)
I discovered that this pattern is used on several other Rails functions.
Why are the default values defined that way? Why not one of these two?
... options = {}, html_options = {})
... options = nil, h...
I've been stuck trying to figure out why a counter cache on my (parent) BlogPosts table won't update from the (child) Comments table. At first I thought the answer provided in my earlier question might be the solution but something happened after I went to bed last night because when I woke up this morning and restarted my Rails console,...
Hi guys,
I have a model Post which has a expiry_date. I want to know what is the
best way to manage scalability in this case. 2 options:
Whenever I want to SELECT from the table, I need to include where
expiry_date > NOW. If the table Post grows like a monster, I will be in
trouble. Imagine after 3 years or more. Indexes will be huge ...
I have body:text content:text sender_id:integer receiver_id:integer in message table
I have this in user model:
has_many :sent_messages, :class_name => "Message", :foreign_key => "sender_id"
has_many :received_messages, :class_name => "Message", :foreign_key => "receiver_id"
I have this in message model:
belongs_to :sender...
I'm looking for a way to dump the structure of an object, similar to the PHP functions print_r and var_dump for debugging reasons.
...
I have a Comment class with a :foreign_key of post_id in the Post class.
class Comment < ActiveRecord::Base
belongs_to :post, :class_name => "Post", :foreign_key => "post_id", :counter_cache => true
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
end
But my CreateComments migration does not define a database...
The following post explains about the page caching in rails with Nginx.
http://blog.hasmanythrough.com/2008/1/30/segregated-page-cache-storage
I like to implement this solution with my app but on Apache.
So, the main block/route is
if (-f $request_filename) {
break;
}
if (-f /cache$request_filename) {
rewrite (.*...
In Ruby on Rails, I sometimes get an error on the page as:
compile error
/Users/jian/ror/shov2/app/views/stories/index.html.erb:13:
syntax error, unexpected kENSURE,
expecting ')'
/Users/jian/ror/shov2/app/views/stories/index.html.erb:15:
syntax error, unexpected kEND,
expecting ')'
the kEND, i can guess that it is End....
there is a line displayed within <pre>
<%= h @stories.inspect %>
and the output was too long, so i changed it to
<%= #h @stories.inspect %>
<% @stories.each do |s| %>
<%= h s.inspect %>
<% end %>
(commenting out the first line). now the code will fail to compile... saying
compile error
/Users/winterheat/ror/shov2/app/views/sto...
OK. This is insane.
I'm new to RoR and I really want to get into it as everything about it that I have seen so far makes it more appealing to the type of work that I do.
However, I can't seem to accomplish a very simple thing with RoR.
I want these controlers:
/admin/blog/entries (index/show/edit/delete)
/admin/blog/categories (index...
I'm getting started building a site with Rails and I would like people to be able to vote certain things with the options of "yes" or "no" or "right" or "wrong". I would also like there to be a running tally computed by percent (maybe below). Could someone tell me how I can add this functionality?
Thanks
...
Hi!
I'm creating a Rails application and on it, there should be a Java Applet.
My question and problem is that the applet must be tightly integrated with the Rails parts. I must be able to get a list of all users, update an image, etc... And there's a surprisingly small amount of information available on the Internet of how to use appl...
it seems that on Rails or erb, the only way to output anything is by <%= %>
<% puts "hello" %> won't work, unlike PHP.
is there any other method at all?
...
some books or even the rails api uses
form_for ...
...
submit_tag ...
end
and i found that the Rails 2.3.2 Scaffold uses
f.submit "Create"
instead... and this is not in the rails api doc. Is this a new
addition and is it suppose to replace submit_tag?
...