Displaying 20 results from an estimated 900 matches similar to: "What is the meaning of the method to_param?"
2006 Feb 01
0
to_param() / url generation Question
I''m trying to implement the to_param method to allow url generation to
be in the format of /:category_name/:article_permalink (as discussed on
page 299 of Agile Web Development With Rails).
I expect that I need to override/implement the to_param method and have
it return the category_name for the category model and the
article_permalink for my article model, but I haven''t
2008 Feb 20
0
#dom_id should use AR#to_param instead of AR#id
Hi,
I have just commited a patch for ActionController''s #dom_id, it should
iternally use AR#to_param instead of AR#id, because #to_param is used
for routing representation of an ActiveRecord inside ActionPack.
You can found the ticket here: http://dev.rubyonrails.org/ticket/11179.
Luca.
--
blog: www.lucaguidi.com
--~--~---------~--~----~------------~-------~--~----~
You received
2007 Jan 24
2
A spec where interaction-based testing breaks down... (at least for now)
Here are the specs:
context "Finding all the stylesheets available to a company" do
setup do
@mock_company = mock("company")
@mock_company.stub!(:to_param).and_return "1"
Stylesheet.stub!(:find)
end
def do_find
Stylesheet.find_available_to @mock_company
end
specify "should convert the company into a parameter" do
2008 Jan 17
4
multiple views, and some routers
Hi, I''m new to Rails (just a Java Programmer tired of having to
configure a lot of xml''s and mapping classes just to make a simple page
(...))
anyway,
I''m experiencing some problems with routers, i''ve created a new project
using Rails 2.0 and created a scaffold for users.
so i have the following:
users/new.html.erb
...
(and the other pages created by the
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec.
I can''t seem to tell rSpec to expect the call @item.user. The
following error message plagues me not matter how I try to fuss with
the mock:
Spec::Mocks::MockExpectationError in ''ItemsController handling POST /
items should redirect to the new course on successful save''
Mock
2007 Jan 30
5
errors while testing resource controller using rpec
I am testing a resource called venue in this piece of code (generated
using script/rspec_resource)
====================
context "Requesting /venues using POST" do
controller_name :venues
setup do
@mock_venue = mock(''Venue'')
@mock_venue.stub!(:save).and_return(true)
@mock_venue.stub!(:to_param).and_return(1)
Venue.stub!(:new).and_return(@mock_venue)
2007 Mar 14
11
path vs. url
When using named RESTful routes, when should one use the
generated ..._path helpers, and when the ..._url helpers? Say I did
this in routes.rb:
map.resources :users
Where should I use users_path, new_user_path, etc., and where should I
use users_url, new_user_url...?
Thanks!
Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to
2009 Sep 01
13
Function Testing Reloading Fixtures before assertion
Hey Everyone,
I have a function test the is failing (despite the fact the function
actually works in the application). I was looking for some debug
advice on how to find my problem.
Here is the test:
def test_should_delete_word
assert_equal ''published'', words(:one).status
debugger
delete :destroy, :id => words(:one).to_param
assert_equal
2008 Nov 26
1
Clearing form fields for a popup
I am using prototype to create modal popups for my login and register
pages, but the fields are populating with the data from certain
variables. For example, I have a show page that finds a user like
so:
@user = User.find(params[:id])
and my form uses:
<% form_for :user, :url => users_path do |f| -%>
so it is populating the form with the data from @user. Should I
rename the @user
2006 Jul 23
4
Anything like with_scope for ActionController?
There are areas of my application that "want" to use a url structure
like
domain/<human_readable_param>/<Module>/<Controller>/<Action>/<Id>
Please note that the human readable parameter I need to inject is NOT
related to the <id> being used by the action/controller pair. It''s
identifying a container object whose contains are operated
2007 May 20
9
How to test for exceptions
Hi folks,
I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed.
Thanks in advance,
Blake
describe VenuesController, "on update" do
before(:each) do
@venue = mock("venue")
2007 Apr 11
13
View Specs Fail with "protected method render"
I''ve got rspec and zentest installed as well as the rspec rails plugin, and
my model/controller specs all pass and work well. I can''t seem to get views
to work though - 100% of the specs fail with:
NoMethodError in ''/users/show.rhtml should render attributes in <p>''
protected method `render'' called for
2007 Jul 12
3
Agh, this is annoying. Why is this happening?
My problem:
Mock ''Task_1005'' received unexpected message :user_id= with (1)
No matter what I do to try to stub that out it will still fail out and give
me that message.
Here is my spec
describe TasksController, "handling POST /tasks" do
before(:each) do
@task = mock_model(Task, :to_param => "1", :save => true)
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do
before do
@game = mock_model(Game, :to_param => "1")
@game.stub_association!(:players, :find => mock_model(Player))
end
def do_get
get :index, :game_id => @game
end
it "should be successful" do
do_get
response.should be_success
end
it "should
2007 Oct 16
2
Does a mock model have to satisfy contraints
I am a little confused to the what happens with the following:
before do
@site = mock_model(Site, :to_param => "1")
Site.stub!(:new).and_return(@site)
end
def post_with_successful_save
@site.should_receive(:save).and_return(true)
post :create, :site => {}
end
I understand that the "@site.should_receive(:save)..." places a check to
whether the
2006 Apr 07
2
ActiveRecord find all based on array -- need ids from array
Does anyone know if it is possible to perform an ActiveRecord find by
passing in an array? I would like to be able to do the following:
MyModel.find(:all, :conditions => ["user_id in (?)", users])
The problem I run into is that the returned SQL contains the to_s()
output of the User object, not the ids of those users. Is it possible
to change this behavior? I attempted to
2007 Oct 06
1
2.0 release train and a tiny ARes fix needs review
Are we too late for minor fixes to hop onto the Rails 2.0 train?
This little guy needs some +1 love. He adds ARes::Base#to_param:
http://dev.rubyonrails.org/ticket/9557
Cheers,
Brad
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to
2006 May 17
6
ActiveRecord#to_param
Hello,
to implement some some kind of optimistic locking, I want to build a
view, where an object is displayed together with a link containing the
data of the displayed object. My first try looked something like
<%= object.object_discription %>
<%= link_to "action", :action => "take_action", :data => object %>
this won''t work because object is of
2007 Nov 18
9
Not sure why this is failing
I am not sure why the tests don''t see the call of the new method for the
Address class. It can be seen in the controller method where the
Address.new is called.
>> @address = Address.new(params[:address])
What am I doing wrong?
Thanks for the help.
Here is the error message:
Spec::Mocks::MockExpectationError in ''UsersController handling POST
/users should create a new
2006 Jul 07
5
link_to: link is missing id
I''m using a legacy table, where the unique id is not ''id''
I have a Model class like the following:
class Article < ActiveRecord::Base
set_primary_key "ARTICLE_ID"
end
however, using a link_to like the following (modified scaffolding),
the link has no id value:
<% for article in @articles %>
<tr>
<% for column in