Displaying 20 results from an estimated 6000 matches similar to: "Modifying "Find" to always add a condition?"
2006 May 17
1
Experiences with ModelSecurity
Hiall,
I would be very interested in your opinions on the ModelSecurity
plugin by Bruce Perens.
http://perens.com/FreeSoftware/ModelSecurity/Tutorial.html
Some time ago, I read on a few pages that it is the way to go, on this
list however, I didn''t read much about it. Apart from it''s security
level,
quoted from comments in source code:
# FIX: At the moment we only support
2006 Feb 16
1
HABTM -VS- belongs_to/has_many, for self-referential joins
Ok, David says on page 241 that sometimes a many-to-many relation with
attributes are better implemented as an actual model instead of using HABTM.
Well, I''ve got that situation and I can''t figure it out.
All of the examples in the book have HABTM examples between 2 different
tables, but I want to have a HABTM relation on 1 table with itself. (e.g.,
if I have a table Things,
2006 Mar 02
17
can''t get rails to connect to mySQL - HELP!!!!!!!!!
Sorry, but this is really NOT as easy as the tutorials/books make out.
I''m really struggling at the first hurdle here. And while I''m not a
programmer by design I do know my way around most stuff. And if I can''t
get this to work I suspect more people will have the same issues. There
seems to be too many variables to address.
I have winXP, I have ruby and rails all
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)
2006 May 02
4
recommended setup of Mongrel_cluster + SSL for multiple apps?
I''d like to use Mongrel_cluster with SSL on a green-field application (it
can be configured however is best - initially, "ease of setup" is important,
but then soon after will be scaling and response time). I''ve read a lot of
emails on this topic, and checked out the Mongrel pages, etc, but I''m left
with this question of what is recommended:
For a
2006 May 02
2
Autotest doesn''t work on WinXP?
When I try to run autotest (zenspider) (which looks VERY cool), I get this
error:
(run from within a Rails app directory)
C:\ruby_home\analysis>autotest -rails
# Testing updated files
+ c:/ruby/bin/ruby -Ilib:test -e ''["test/unit/user_test.rb",
"test/unit/role_test.rb"].each { |f| load f }'' | unit_diff -u
''c:'' is not recognized
2006 Aug 16
3
calculate method is gone once I use ''find''?
Could someone please explain why this works:
current_user.accounts.sum(:balance)
But not this:
current_user.accounts.find_all_by_active(true).sum(:balance)
For the latter Rails tells me sum is an undefined method. It seems like
I lose the ActiveRecord methods when I call ''find''?
This (simpler) does not work either:
current_user.accounts.find_all.sum(:balance)
Thanks!
--
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]
2006 Feb 14
4
Fine grained access control
Hi,
I''m building an application which is going to require quite fine grained
access control. Deciding if a user is allowed to access an action will
probably require checking quite number of different rules, so a simple
role-based system won''t be flexible enough.
The approach I think I will try first is, if it''s possible, to ignore
permission issues inside the
2007 Mar 13
5
Question on application/database design for a application port to rails
Hi all
I am hoping that the experience and knowledge of this ''list'' will be
able to help me out with some design decisions I have to make while
porting a desktop app to rails.
Here is the scoop:
I am in the design process of porting a fairly large client/server app
to rails. Average data set is about 200 MB per database/server.
Altogether there are about 100 tables and about
2007 Oct 18
9
with_scope issue
I have the following code:
class User < ActiveRecord::Base
has_many :requests do
def find_active(options = {})
with_scope :find => { :conditions => ["requests.active = ?",
true] } do
find(:all, options)
end
end
end
end
Executing user.requests.find_active results in the following SQL:
SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND
(
2006 Apr 04
4
Membership Management System Plugin/Gem?
Hi, I''m looking to create an online internet community for managing
user profiles and other data. Thus, I would need that has the
following features:
o authentication
- protect individual member pages/directories
o session management
o retrieve and reset passwords
In short, I''m looking to create an online community. Thus, can
someone direct me to a plugin(s) for
2006 Jan 16
2
LoginEngine vs. LoginGenerator?
I just saw a mention here of LoginEngine, which I hadn''t heard of
before. Last week when I was digging for user-account sample code for
my web-app, I instead found the LoginGenerator and started using that:
http://wiki.rubyonrails.com/rails/pages/LoginGenerator
Is one of these preferred over the other? From skimming the API docs,
it does seem that LoginEngine has more features,
2008 Apr 07
7
Saving attribute
Something is getting lost here.
def create
@home = Team.find_by_user_id(current_user.id)
for player in @home.players
player.update_attribute(:game_id, @game.id)
end
end
def show
@players = Player.find_all_by_game_id(params[:id])
end
view
<%= @players.size %> # mistakenly equals zero
Played with the console and everything should be working fine...
2006 Jul 17
10
getting the user name
Hi I am new to ruby and trying to obtain the user name in the login
index.rhtml where I could display "You have logged in [user name]"
How could I do this? I have been trying different options after reading
the ruby manual but still throw an error.
please help
--
Posted via http://www.ruby-forum.com/.
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all
actions...and their views?
eg.
class ApplicationController < ActionController::Base
@current_user = User.find(session[:user_id])
end
and everywhere I can call @current_user.id and I can get that object? Even
down in the views?
I could not get this to work...
Thanks in advance,
Jeff
-------------- next part
2006 Mar 16
6
Sessions or lookups?
My application needs to know if a user is an administrator, for security
and aesthetic reasons. At the moment, I store true/false in the session
by doing the following at login:
session[:user_is_admin] = authenticated_user.is_admin?
Is this OK to do? Or should I really be doing the following every time:
User.find(session[:user_id]).is_admin?
(user_id is always in the session too)
Is there
2006 Mar 12
3
Newbie: using find like a sql join query
I have a working Rails app with several related tables, but can''t find
an answer to this question in the Dave Thomas Rails book. Imagine for
example:
table departments with columns: id, department_name
table employees with columns: id, department_id, employee_name
and of course the employees table has a constraint foreign key
(department_id) references departments(id)
So this is
2006 Apr 27
5
def list - paginate question
How do I adapt this code to only list articles made by the user logged
into the session?
def list
@article_pages, @article = paginate :articles, :per_page => 10
end
--
Posted via http://www.ruby-forum.com/.
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