Displaying 20 results from an estimated 74 matches for "with_scop".
Did you mean:
with_scope
2006 Nov 01
17
So how can I rewrite my app without using with_scope?
So, I hear that with_scope is going to be deprecated.
Which is a bit of a shame, given the stuff I''ve been writing recently.
I have a CMS with multiple clients. A ''client'' is essentially a
company, with multiple users. Content on the site belongs to a client
- content could be messages, image...
2006 Apr 01
1
STI with_scope on parent - bug or feature?
Hi,
It seems that setting a with_scope on the parent class doesn''t do anything
MyClass.with_scope(:find=>{:conditions=> ["somecol = ?", ''val'']}) do
@ext_pages, @ext_rows = paginate :my_extended_class, {
:per_page => 13
}
end
# this doesn''t generate WHERE somecol='...
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
( requests.active = 1 )) AND (requests.u...
2006 Jul 14
5
Acts_As_Taggable Plugin multiple controllers.
I have Acts_As_Taggable Plugin working. I have a HR controller and a
sales controller.
I have a document in hr tagged whitepaper and a differnent document in
sales tagged whitepaper
when I am in hr I see the hr document tagged with whitepaper and not
the sale document (what I want). but if I click on the tag whitepaper
I return two documents, hr and sales. I just want to return the hr
document
2006 Jul 23
0
[PATCH] (+tests) with_scope :order doesn''t work with included associations
(I''ve had this patch lying around for a couple of weeks, waiting for
Trac to come back up. noradio''s already had a look at it on IRC.
What''s the best way to submit patches while Trac is down?)
with_scope doesn''t support :order in the presence of :include. For
example:
{{{
# We''re testing the interaction between :order, :include, and
with_scope.
TEST_ORDER = ''tickets.created_at DESC''
TEST_INCLUDE = [''owner'']
def test_find(opts1, opts2)...
2006 Apr 03
0
with_scope used in a has_many :through model
Hi there,
I have something like the following:
class Person < AR:B
...
...
has_many :votes
has_many :chosen_answers, :through => :votes, :source => :answer, :select => ''DISTINCT answers.*'' do
def my_answers(whodunnit)
chosen_answers.with_scope(:find => { :conditions => [ "votes.created_by=?", whodunnit ] }) do
chosen_answers.find :all
end
end
end
Its somewhat of a contrived example, but I''m trying to understand if/how
it can work.
If i try:
p=Person.find :first
p.chosen_answers.my_answers( Perso...
2006 Mar 02
0
EdgeRails with_scope and :select
>From what i can gather the with_scope feature doesn''t allow you to
specify which columns get selected. It appears to default to "*". So
if i specify something like:
Question.with_scope( :find => {
:from => "questions q, answers a",
:conditions => "q.owner = a.owner AND a.owner=1"
}...
2006 Mar 30
4
with_scope and filters for Rails 1.1 (scoped_access plugin)
Has anyone successfully gotten the scoped_access[1] plugin to work in
Rails 1.1? Some of the methods it was relying on are now no longer
accessible. It seems the only way to add scope is to use the
''with_scope'' method that takes a block, but since Rails doesn''t have
real around filters[2] I cannot see a way of adding a scope using a
filter.
Anyone using with_scope and filters that can shed any light?
Cheers,
Jon
[1] http://habtm.com/articles/2006/02/22/nested-with_scope
[2] "...
2010 Jan 27
1
around_filter and with_scope
...s a security check that enforce a simple spec: normal user
should read/write information only about their group''s users, but
"admin" users can read/write about all users.
The other controller is quite similar, just on another model.
trying to refactor a was reading about using a with_scope in an
around_filter.
this seems to work and the code gets a lot smaller. But it seems to be
a deprecated practice...
What is the "rails way" to accomplish this?
thanks.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
T...
2006 Jul 23
4
Anything like with_scope for ActionController?
..._start_tag, named_route_url...) to get the mapping to pick up the
custom URL parameter. Having to remember to
append :short_name=>@my_object.short_name (with or without to_param
magic), is getting annoying and the repetition is getting ugly.
Is there anything like ActiveRecord''s with_scope function to "bind"
this extra parameter once and make ActionController smart about
propagating the extra parameter everywhere?
Thank you.
Eric
2006 Jun 26
0
with_scope with new
Why does with_scope work with .create, .find, but not with .new? It
breaks all scaffolded code :(
--
Posted via http://www.ruby-forum.com/.
2006 Sep 08
1
has_many relationship extensions and scoping rules
Hi all !
Is this supposed to work ?
class Email < ActiveRecord::Base
has_many :to, :class_name => 'Recipient', :conditions =>
"recipients.source = 'to'" do
def create!(*args)
with_scope(:create => {:source => 'to'}) do
super
end
end
def build(*args)
with_scope(:create => {:source => 'to'}) do
super
end
end
end
end
From my tests, if I call Email.to.create!, the recipient model
correctly has it's sour...
2006 Nov 21
2
Accessing scopes
If with_scope has been called previously, how do I access the find
conditions dynamically?
I am asking because I am using a find_by_sql call (which clobbers the
with_scope). How can I access the method scoping so that I can read it
and incorporate it into my query manually?
--~--~---------~--~----~----------...
2007 Aug 21
3
Eager Loading
is there a way to always eagerly load an associated object so that you
don''t have to put :include into every finder?
class Product <ActiveRecord::Base
belongs_to :user #always load user when product is loaded
end
Product.find(1).user.login
#1 query since user was loaded with the product, same as if i
used :include but I don''t want to have to specify it everywhere.
2006 Jul 02
11
Rails Plugin: meantime_filter for controllers (actions within blocks)
...of this message for getting it.)
ABOUT THE PLUGIN
It extends ActionController to add the functionnality of having
filters run at the action call time. This new type of filter yields
when the action has to be performed. Especially, it enables one to
use all the power of the ActiveRecord::Base.with_scope class method
in actions.
For example (in a controller definition):
before_filter :authenticate # Sets @user to the logged in user
meantime_filter :scope_to_user, :only => :list
# Displays the posts of @user only.
def list
@posts = Post.find(:all)
end
private
def scope_to_user...
2010 Dec 16
12
Capybara + radio buttons
How do I select a radio button when both id and name are identical?:
<input type="radio" name="BILFPB.bilPremieUppgifterFI.under24"
tabindex="13" value="J24" checked="checked" id="forare">Ja
<input type="radio" name="BILFPB.bilPremieUppgifterFI.under24"
tabindex="14" value="N24"
2009 Apr 19
19
Controller spec: testing that scope is set
In a Rails controller I set the scope on a model class in an around
filter. I have defined expectations on the model classes, and ideally, I
would add a further expectation for the scope. Is this already possible
in some way? How would I go about adding support a scope expectation?
Michael
--
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/
2006 Mar 04
4
authorization framework?
There are a number of good authentication frameworks for rails - has anyone
developed a generic authorization framework?
I''m thinking of something that included the concept of roles, mapped roles
to both actions and users and could be used to wrap actions before their
invocation.
Extra good would be some way to check data permissions (as in, "yes you can
perform the ''Edit
2006 Feb 01
7
Explanation of "alias_method"
Hi!
I''m trying to extend ActiveRecord''s find method (Rails 1.0, Ruby 1.8.2),
but I recognize a strange behaviour of the "alias_method" call.
I wrote a very simple script to explain my problem:
------------------------------------------------------
module ActiveRecordExtension
def self.included(base)
base.extend(ClassMethods)
base.class_eval do
2006 Jun 26
0
How to limit access to model objects based on role?
...of the access control
systems out there to limit access to the controllers. However, with 9
different controllers this seems like a terrible choice.
Here''s what I''ve come up with. Each controller implements something like the
following code. Basically, there''s a set_x_with_scope method which takes
normal find() parameters, then passes them to X.find within X.with_scope.
So, instead of having @category = Category.find(param[:id]), which would
occur multiple times in the controller, I use
set_category_with_scope(params[:id]), which sets @category and only allows
access to...