Questions tagged [scopes]

An OAuth Scope is a permission setting that limits the permissiveness of a given OAuth Token. Clients therefore provide a list of desired Scopes when obtaining a Token (alongside standard OAuth ClientId and Client Authentication details). The Token will then be granted (or not) according to the Authentication process and the Scopes granted for the given Client Id

383 questions
0
votes
2 answers

Yii: Getting distinct field values from a related model using scopes

I'm working on the Admin view in Yii for my Project model. One of the columns with a filter is user (owner) of the project. I can do something like this: 'filter'=> CHtml::dropDownList('Project[user_id]', $model->user_id, …
McB
  • 1,082
  • 1
  • 18
  • 36
0
votes
1 answer

Accessing associated fields in merged scopes

Model: A vehicle has_many mileage readings entered (in this particular case, a vehicle is running on an hour meter). In the view I need to display the largest hour reading entered for each vehicle. This includes displaying several fields about the…
jared
  • 231
  • 3
  • 13
0
votes
1 answer

Creating and Using Scopes In Active Admin

How do i use scopes in Active Admin, In this example I am trying to display all members who's expiry date is equal to today's date. class Member < ActiveRecord::Base --- Code removed for brevity #Scopes scope :expired_today, where(:expiry_date…
Richlewis
  • 15,070
  • 37
  • 122
  • 283
0
votes
1 answer

Using Rails association methods versus scopes

When is it appropriate (if ever) to use association methods instead of scopes? Here's an example that I think warrants association methods over scopes: I want to be able to get the current, complete accreditation for a user by invoking something…
Lars Levie
  • 795
  • 6
  • 9
0
votes
1 answer

How to delete information in jsf pages, which use a session managed bean as data resource?

i have a question concerning two java beans, which was declared in faces-config.xml and have two different managed-bean-scopes in JSF 1.2. First of all i would like to explain the problem, which i have now. I have the possibility to export some…
user2504767
0
votes
2 answers

Is it possible to get a parent's id in a ActiveRecord model's scope method?

Say you have a Game model which belongs_to two Teams. class Game < ActiveRecord::Base belongs_to :home_team, class_name: "Team", foreign_key: "home_team_id" belongs_to :away_team, class_name: "Team", foreign_key: "away_team_id" end A team can…
you786
  • 3,659
  • 5
  • 48
  • 74
0
votes
1 answer

scopes in a JSP page

I am new to JSP. I am writing a JSP page named as success.jsp. In my success.jsp, I am creating a String[] array. <% String[] s={"A","B","C"}; request.setAttribute("a",s); %>
reddy
  • 667
  • 2
  • 9
  • 19
0
votes
3 answers

scripting elements in a jsp page

I am new to jsp. I am writing one "declaration" and one "scriptlet" in a jsp page. But the variables i created in declaration and in "scriptlet" does not store in any one of the scope. ie page scope,request scope,application scope.why. Here is…
reddy
  • 667
  • 2
  • 9
  • 19
0
votes
1 answer

rails scope for map table

I have the following models: class Message < ActiveRecord::Base has_many :read_messages module Scopes def by_read_status(read_status, user_id) case read_status when 'Unread' when 'Read' …
Sean
  • 1,078
  • 14
  • 25
0
votes
2 answers

using scopes with parameters and has_and_belongs_to_many associations with ActiveRecord (Ruby)

In my Sinatra app my model defines a HABTM relationship between Users and Notifications. I am trying to define a couple of scopes, one for all Notifications associated with no Users called unread and one that returns all Notifications that are…
0
votes
0 answers

Rails: Better understanding dynamic scopes

This is my "dynamic" scope: def all_games(conditions = {}) scope = games.includes(:stats).scoped {} scope = scope.where sport_position_id: conditions[:sport_position_id] unless conditions[:sport_position_id].nil? scope = scope.where…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
3 answers

How would I create an activerecord scope(s) that would return customers who's next visit resulted in a purchase

I have three activerecord models: Customer, Visit and Campaign. Customer has_many :visits Visit belongs_to :customer Campaign has_many :visits The Visit model tracks everytime a particular customer visits a website, pages…
Mutuelinvestor
  • 3,384
  • 10
  • 44
  • 75
0
votes
1 answer

Set ActiveRecord Scopes In A Loop

Why doesn't this work? class Foo ... Status.each do |status| scope status, where(status: status) end ... end Now Foo.new it returns not an instance of Foo but an ActiveRecord::Relation.
Tim Scott
  • 15,106
  • 9
  • 65
  • 79
0
votes
1 answer

Rails Association, Scope, JoinModel

UPDATE: Here is how we settled it. ran MYSQL Explain on the sql generated by both snippets of code: Manifest.where(assembly_id => @assembly.id).where(part_id => @part.id).exists? NO JOINS AND RAN FASTER -- SO IT WON! I have the following…
RidingRails
  • 782
  • 3
  • 7
  • 21
0
votes
1 answer

How to use scopes in rails to query the database for a subset of information and display it in a view?

I am a beginner and I appreciate an answer to help me understand where my knowledge gap is: The app is to display a post. The posts belong to a category (appetizers, entrees...) My thought was to use scopes to display all the appetizers on the…
akkdio
  • 573
  • 2
  • 5
  • 13