Spree 1.3: How to only show users products available in their size [closed] - ruby-on-rails

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm collecting size information from my users, so when they view the main products page, they only see products that are available in their size. I think the solution involves product scopes, but I'm not sure how to implement it. Anyone have any ideas on the best way to implement this?

The logic to find the products to display is generally done by:
https://github.com/spree/spree/blob/v2.1.1/core/lib/spree/core/controller_helpers/search.rb#L5-L9
An example of it being used is here:
https://github.com/spree/spree/blob/v2.1.1/frontend/app/controllers/spree/products_controller.rb#L10
By default, it will use this code to find the products
https://github.com/spree/spree/blob/v2.1.1/core/lib/spree/core/search/base.rb#L15-L24
In order to override this, you can override the searcher_class configuration:
https://github.com/spree/spree/blob/v2.1.1/core/app/models/spree/app_configuration.rb#L101-L108
The searcher class has access to the current user, and I'm assuming you've modified the current user to contain their size.
You can do a crazy-ish query to get all products of a certain size. For example:
Spree::Product.joins(:variants_including_master => :option_values)
.where('spree_option_values.presentation = ? AND
spree_option_values.option_type_id = ?', 'XL',
Spree::OptionType.find_by_name('tshirt-size').id)
Replace 'XL' with current_user.size or whatever you have setup, and you should have things working.
Hope that gives you a good place to start.

Related

cxBarEditItem will not accept adding items [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
My cxBarEditItem1 has properties : combobox.
However when I begin to write :
cxBarEditItem1.Properties.Items.Add ...
Delphi shows me it's an error. It seems 'items' do not exist.
What am I doing wrong ? How can I fill it ?
The compiler doesn't know that cxBarEditItem1.Properties refers to a ComboBox at runtime. You have to cast to tell it:
Assert(cxBarEditItem1.Properties is TcxComboBoxProperties);
TcxComboBoxProperties(cxBarEditItem1.Properties).Items.Add('Hello');
I don't have the DevExpress Expressbar controls... But I have downloaded the help file for the components. I can recommend the help, it's very useful.
From what I can see, you really want to put a TcxBarCombo on your bar, which does have an items property.
I think you have dropped a non-ribbon style Combo on to your ribbon, which may be a separate component on your form... Maybe try clicking on the combo and seeing what the component name is in the object inspector, then use that name to add items to the control.

How to play many wma files in a loop [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
How can I play 20 wma files on delphi using Tmediaplayer, one after another in a continues loop until the program is closed ? I already tried using a timer for each file , but I keep failing. I have 20 songs that I'd like to play in the background while the rest of the program runs.
Put the filenames into a list. Set the TMediaPlayer.FileName property to the first filename in the list, set the TMediaPlayer.Notify property to true, and call TMediaPlayer.Play(). When the TMediaPlayer.OnNotify event signals playback has finished, you can assign the next filename in the list to TMediaPlayer.FileName, reset TMediaPlayer.Notify to true, and call TMediaPlayer.Play(). Repeat for each filename in the list. One you have played the last filename, start over with the first filename.

Recognize Specific Characters In a Text [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
hy
im making an app to help students study better but im having trouble. the app let you make notes between other things,but I need a code that can recognize specific characters in a text for example the user writes in a note "Dolphins : are cetacean mammals closely..." i need the app to recognize the character : and also the part thats on the left it needs to be save to use later, as a variable and the part of the right also but as a different variable so I can use them later.
if you can get me the code for that it be great but if possible i preferred a tutorial :)
(the app is for iPhone im using Xcode 5)
Something like:
NSArray *stringArray = [yourNSString componentsSeparatedByString:#":"];
NSString *leftString = stringArray[0];
NSString *rightString = stringArray[1];
EDIT: Just make sure string has the ":" character.

Use object with variable name in Delphi [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm new in delphi and i thought it might be safer to swap object names in loop instead of copying whole block for each object. So I need to use variable name as some objects name.
Here is an example of what i tried and what i am trying to do.
Var
YazGrid: TStringGrid;
I defined a variable for grid name as above and i am trying to use like this:
Some Loop
begin
if a_variable>=10 then
YazGrid:=form1.StringGrid1
else
YazGrid:=form1.StringGrid2;
YazGrid.Cells[1,i] := 'SomeText';
End;
As the result- it comes out with the "Access Violation" error. How should i do this?
Thanks in advance.
Everything looks right in your code.
Make sure that variable "i" in bound. Anyway, even if "i" out-of-bound, this shound't raise Access Violation.
Tested with Delphi XE2 and XE4.
I suppose that error occure in code that not showed in your sample.

Ruby how to extract element value from a data structure [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
x = {"utf8"=>"✓",
"authenticity_token"=>"xxxxxxxxxxxxx=",
"file"=>#>,
"unit_id"=>"00001"}
I have ruby data structure like this and um trying to get the value of #original_filename field
I tried something like this
x["#original_filename"]
and
x[:original_filename]
But both has thrown me an error . How to access that specified element value?
looks like you're trying to upload a file; from your tiny screenshot maybe you're referring to params[:file].original_filename?
The parameter ["file"] is a ActionDispatch::Http::UploadedFile, which has the original_filename member variable, as you can see in the params displayed in your image or here:
http://api.rubyonrails.org/classes/ActionDispatch/Http/UploadedFile.html
So, the way to get this value would be x["file"].original_filename

Resources