Displaying 20 results from an estimated 5000 matches similar to: "Caching of models?"
2005 Dec 25
4
How to display a welcome page
Wow, I can''t believe that after a few weeks of playing around with Rails I
got stuck on something that seems like it should be really simple.
How do I display a default welcome page for visitors who are not logged in
and send logged in users to the appropriate controller. I am using the
login_engine and the user_engine.
The two methods I have seen looking at sample code are to stick a
2005 Dec 26
2
special characters in rhtml
Is there any pattern how to use non-english fonts right in rhtml file? Using
ą is frustrating.
Thanks,
Szczepan
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
2005 Dec 26
3
data insertion in multiple tables
I have two tables like:
Table A:
id (autoincrement)
name
Table B
id
id_of_A
desc
I want to add a record to table A and based on the id of A, I want to add a
record to table B.
I don''t think there is any SQL command that support this (at least in MySQL
4.1, so I use LAST_INSERT_ID()).
(Is there any other way? or MySQL 5 support any special SQL command?)
But I need
2006 Apr 08
5
Creating sub actions
Hi,
So finally I have also decided to roll my engines on Rails. But I am
kind of stuck in a situation. I understand that for every model there is
a controller class. This controller class has cirtain set of methods
where each method defines cirtain action to be performed. And each of
this action renders cirtain UI.
[The background]
Now let say I have a object "Car". Apart from
2006 Jan 11
6
Help -- NoMethodError in
Hi,
I am just learing Rails and I am going through the Agile Web Development
with Rails book. I am receiving:
NoMethodError in Store#add_to_cart
undefined method `add_product'' for #<StoreController:0x3764d80>
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/controllers/store_controller.rb:12:in `add_to_cart''
2005 Dec 26
5
show render time on pages
hello all!
is it possible to access the render time variables in the view? i would
like to show
Completed in 0.09574 (10 reqs/sec) | DB: 0.08729 (91%) | 200 OK
[http://localhost/person]
on each page like in the logs.
how can i do this?
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture-
driven way of spec-ing or mocking. How the heck to you mock this so
the code at line (2) and (4) work right? I''m still struggling with
mocks but it seems like this can be done. Forgive the naivety of this
question.
1. def change_quantity
2. @line_item = LineItem.find_by_id(params[:id])
3. unless
2006 Apr 14
2
Puzzled with filters
Hello everyone!
I''m trying to create an after filter for all my actions in all
controllers. I put it in application controller (application.rb).
class ApplicationController < ActionController::Base
after_filter :tidyit
def tidyit
xxxx # syntax error - intentionally
end
end
I have a Example (example_controller.rb) controller with index action.
class
2006 May 03
8
Subversion and tmp directory in Rails 1.1 project
Hello everyone!
I''m thinking of the right way to store tmp/ directory of Rails 1.1
project in Subversion. It has cache, session and sockets
subdirectories. To me, it looks good to have
svn delete tmp/*
svn propset svn:ignore "*" tmp
So it will ignore all directories and files in tmp/. Even if you
create sessions/ and put some files in it, tmp/ content is still
ignored.
But
2007 Aug 30
3
Rails - depot application
I''m doing the depot example in the Agle Web development book. I''m
getting this error:
"undefined method `product'' for #<BigDecimal:331ce70,''0.21E1'',8(8)> "
"Extracted source (around line #9):
8: for item in @items
9: product = item.product
10: -%>
11: <tr>
12: <td><%= item.product%></td>"
2006 Aug 15
3
update or alter cart
I want to modify and update the items in the Depot - "display_cart".
Since the cart is in a session, its a little hard to get at the data.
I just want to create a way to change quantities, prices and
recalculate.
Has someone done this, and could you point me to the right direction.
Thanks
Chas
--
Posted via http://www.ruby-forum.com/.
2006 Jan 31
2
asigning values to atributies when source is nil
I want to use something similar to the following:
@total_price += { product.price <> nil ? product.price : 0.0 }
This fails in rails with a "nil can''t be coerced into Float" error.
What is the (most) correct way to do this?
On a related issue, what is the significance of the value 40
following "cart.rb" in the trace snippet below? The entire class
file
2006 Mar 20
5
Google AdSense question to Rails community
Hello everyone!
I''m not sure if it''s right place to ask, but what is your experience
with google adsense? I plan to implement free web service for
community and would like to cover hosting costs. Is adsense worth the
hassle?
olegf
2007 Oct 19
14
Agile Web Development Book, need a bit of help
I''m working my way through the book Agile Web Development with Rails,
and I am in the section where the book has me creating a display_cart
method and the associated view. When I copied the code from the book
into the view, it threw this error. If anyone could give me some hints
where I should be looking I''d appreciate it.
NoMethodError in Store#display_cart
Showing
2006 Mar 05
3
"Undefined method" problem in "Agile Web Development With Rails"
Hi,
I''m reading the "Agile Web Development With Rails" book. So long,
everything has worked fine, but now I got this annoying error message
that I just can''t understand. The error appears for me around page
87, chapter 8.
NoMethodError in Store#display_cart
Showing app/views/store/display_cart.rhtml where line #28 raised:
undefined method `product''
2006 Apr 24
3
Form with multiple rows of content
I have looked at examples for this. I found a similar example in the
Agile Web Dev... book but that didn''t help. Here''s what i am trying to
do.
A Cart has many line items. On the Display Cart page, I want to provide
the user the option to update quantities.
Here''s the rhtml code:
<%= start_form_tag :action => ''update_cart'' %>
2005 Dec 23
6
Agile book - test error
Hi all,
I get an error when testing the "store_controller_test.rb"
The troublesome line is in the test below:
def test_add_to_cart
get :add_to_cart, :id => @version_control_book.id <<<
cart = session[:cart]
assert_equal @version_control_book.price, cart.total_price
assert_redirected_to :action => ''display_cart''
follow_redirect
2006 Apr 16
9
''depot'' app, where''s session?
Many of you probably know the ''depot'' app from the ''Agile Rails
development'' book.
I have constructed the ''products'' model, the Store-controller, and the
''Cart'' and ''Line Item'' classes. I have told Application-controller about
:cart and :line_item:
model :cart
model :line_item
Here''s part of
2006 Aug 13
3
Logging in Rails
This is a newbie question, I have a class which is not derived from
ActionController or ActiveRecord but I want to use logging, I tried require
but still logging does not work -
This class is located in a file in "model" directory.
------------------------------------
require ''logger''
class Cart
def add_product(product)
logger.info("Searching for product
2006 May 08
6
how to make field in model immutable after create
Hello everyone!
I want to have login field in User model which is set only once (on
create), and then it should fail validation if the value is changed.
How can I do this? I dig around for validation and tried
def after_validation_on_update
unless User.find_by_login(:login)
errors.add(:login, "is immutable. You can''t change it")
end
end
in model, but somewhat it