Displaying 20 results from an estimated 2000 matches similar to: "Set instance variable for all actions in the Controller"
2006 Oct 09
5
Problem setting variables in ApplicationController.
I''m dynamically generating menu options based on the currently logged
in user: current_user.
My menus are setup on the applicatin.rhtml file. The current_user is
defined in the application controller. But, attempting to assign it a
value while in the application controller results in an ''undefined
method'' error.
ApplicationController ....
def current_user
@cu =
2006 Jun 15
13
Best Approach to a ''Down for Maintenance'' Page?
What is the best way to implement a ''Down for Maintenance'' page across
your Rails app?
Ideally I would like to have a button in my admin section that toggles
the display of a ''currently under maintenance'' page to every public
request to the app (possibly with some dynamic content like estimated
down-time)
except for: -
- requests from a specified IP
2006 Apr 19
4
Another DRY question
I have some code working that lists only items from a particular user.
The code in my list action finds the user and then conditionally lists
only his/her items:
def list
user = User.find(session[:user])
user_id = user.id
@product_pages, @products = paginate :products, :per_page => 10,
:conditions =>[''user_id = ?'',
user.id]
2007 Jul 17
12
Getting past my login system
Thank you in advance for your help. I am relatively new to both Rails
and Rspec and I am hoping for some insight from some experienced veterans.
Right now I am using Rspec for code that has already been written so
that additional functionality can be developed using the BDD method. My
problem shows up when I try to spec controllers that are behind the
login system. Each page checks for the
2006 Apr 23
3
ANN: Polygons library + sweet demo
Hello!
I''m releasing an extraction from an application I''m currently working
on. It''s a small library for dealing with points and polygons, called
Polygons. It really just implements some textbook algorithms w/
Prototype-style JavaScript classes. Check it out here:
http://polygons.mdaines.com/
The demo on that page (Firefox/Safari only right now) uses the
2006 Jun 06
1
Default value plugin
I''m releasing a very small plugin that allows you to specify default
values for fields in models. Ordinarily, you might do this in your
schema, I guess, but then it''s awkward if you need that on a
serialized field or need your default values calculated somehow.
So you can do something like this: (repeated from an earlier post and
the README)
class Mixture <
2006 Jun 14
2
Can pagination work with caching
I am currently caching a page that indexes blog entries. Paginate was
used to break the entries up. Now when you click on next at the bottom
of the page it is only reloading the first page. Im hoping, against
odds, that someone here knows of a way to make paginate and cache play
together.
--
Posted via http://www.ruby-forum.com/.
2006 May 31
7
Getting 22 elements
Hello,
I''ve done
===
class HomeController < ApplicationController
def index
@country = Country.find(:all, :include => "cities")
end
end
===
And rhtml is:
===
<% @country.each do |country| %>
<h1><%= country.name %></h1>
<% country.cities.each do |city| %>
- <%= link_to city.name, :action =>
2006 May 03
4
default values
Hello,
I''m working with a postgresql table
CREATE TABLE elements (
id serial primary key,
c1 text default f1(),
...
cN text default fN()
);
But if I use de lines
@element = Element.new
@element.save
the values that element take are the nextval in the id field and nules in
all the other fields.
How can I get the defaults?
(but without rewriting the
2006 May 22
6
which kind of deployment has the best performance
In the following deployment of web app on ONE pc-based server,running
linux,which can support the most amount of concurrent users as well as
the shortest latency?
1 apache+mongrel
2 apache+mongrel_cluster
3 lighthttpd+mongrel
4 lighthttpd+mongrel_cluster
5 lighthttpd+fastcgi
Thanks
charlie
--
Posted via http://www.ruby-forum.com/.
2005 Aug 17
2
CumulativeOffset
Hey All,
I have a fairly basic question about the prototype.js library. First,
I''ve been looking for documentation on this and I have yet to find it.
If any of you know of any, please let me know. Since I''m new to both
the scriptaculous and prototype libraries could someone explain why I
would want to use the cumulativeOffset method and not to just grab the
offset off
2007 Sep 13
5
Authenticating before tests
Hi all,
I''m using Goldberg, an engine that provides roles based access
control for my app. I need to login before I can do controller tests,
but I can''t find any examples of people doing this.
Could someone point me in the right direction?
I thought the simplest way would be to either call the login action
from my other tests before(:all), but I can''t seem to
2006 Jun 01
3
more questions: human_name
One more question:
Is there some way to set the human_name of a column? e.g.: human_name
for column address1 shouldn''t be Address1 but "Address, line 1".
If not, should I make a hash with my custom names?
Best regards,
--
----------------------------------------------------------------------
Yannick Majoros http://www.inma.ucl.ac.be/~majoros
Informaticien UCL/INMA-MEMA
2007 Jan 26
10
Camping and DBI
Hi,
I''ve been playing around with using DBI instead of ActiveRecord ''cause
I just love to beat myself up! ;) Is this an okay way to do this, or
is there any other more creative ways?
require ''dbi''
module MyApp:Models
class DB
def self.dbh
DBI.connect(''DBI:Mysql:dbname'', ''username'',
2006 Jun 01
1
Default Value for date_select helper
Hi All:
Just curious if anyone has figured out how to set a default date for the
date_select helper.
My application has a form with both a start date and end date select for
the user. Since the period between the two is a minimum of 24 hours I
wanted to have the start date default to Date.today (which it does
automatically) and then have the end date default to the following date
(i.e.
2006 May 21
3
Catching events outside document (on window chrome)
Hello,
How can I catch the onmouseup event outside the ducument - means when
the pointer is above window chrome (e.g. toolbar)?
Event.observe(document, ''mouseup'', someListener) works only inside the
document for me.
Thanks in advance for your help!
Thomas
--
Posted with http://DevLists.com. Sign up and save your mailbox.
2006 May 31
2
calling routing during a functional test
I had a beginner''s question. I am testing the create action on my
controller. I wanted to fetch the ID parameter of the newly created
object, so that I can make some assertions on it.
But I can''t seem to find an elegant way of doing that. Of course, might
create action redirects. That means that @response.redirect_url is
something like "/show/8". So I could pluck
2006 May 31
3
validate unless, LoginGenerator difficulty
I apologize if this is a very simple question; I''ve searched the forums,
wiki, Google, and Agile Web Development with Rails to no avail.
Is there a way to put conditional validation in the model? For
instance, if I want to limit items a user can add unless the user is an
admin? My current code is:
validates_uniqueness_of :user_id, :scope => ''event_id'',
2006 May 30
2
acts_as_queue
wondering if anyone tried this patch. (i havent, seeing as its 1228
lines long, 10 months old, and cant take serious a patch many orders
larger than competing web frameworks)
in many cases i want to keep about 10 things around, eg recent searches,
new items (spanning multiple classes), referers, page views, without
logging them for perpetuity. so i guess this isnt a normal queue, more
like a
2006 May 18
2
Help with Routes
I love the routes feature for RoR...until now. I''m trying to write tests
to make sure my urls are correctly mapping to the routes I expect them
to map to. This is driving me nuts because I simply can''t get any of my
tests to pass. I have thus concluded that routes must work differently
than I thought. I will try to explain my understanding of how routes
work. Via this