Tagged Questions
1
vote
2answers
98 views
Mustache Conditions and Loops
Here are the resources:
JSON
{
"badges":{
"unlocked": [
{"name": "Win 1"},
{"name": "Win 2"},
{"name": "Win 3"}
],
"locked":[
{"name": "Lose 1"},
{"name": ...
1
vote
0answers
77 views
Conditional has_many relation in rails 3.2
i'm getting data from a third party with own unique keys.
Level1, data_provider_id
Level2, level_1_id, data_provider_id
Level3,level_2_id, data_provider_id
Relations for level1.rb
has_many ...
0
votes
1answer
38 views
Rails controller and action specific titles from application_helper
Each page of my site has a unique title. I'm repeating myself and adding code to multiple pages when I feel I can do this with a layout and helper. I'll show my working code and the solution I'm ...
0
votes
0answers
62 views
Thinking Sphinx how to OR search_options[:conditions] attributes in using Model.search()
I am very new with Thinking Sphinx, working on a project coded by people I no longer have a line of communication with. I am currently trying to fix a search that is set up in our application.
We ...
0
votes
2answers
77 views
Rails 3.2.5: Simple issue with search, need to return 'No Results Found' if nothing is found
I've looked at a few Railscasts and I know this is pretty simple but can't get it set up.
The actual SEARCH itself is working OK.
If I type in say, 'we' for example, it returns all the results with ...
0
votes
2answers
57 views
Rails - link to new action instead of show if an item doesn't exist?
I'm trying to create a link so that if the current user has a project already created, then they just click the 'Project' link, and it will take them to their project. Each user can only have one ...
0
votes
2answers
93 views
Rails search through array of arrays
I have an array of arrays like so: [[1, "dog"], [2, "cat"], [2, "bird"], [3, "monkey"]]. I want check if the larger array contains arrays of a given number without regard for the animal element of ...
0
votes
1answer
158 views
ruby on rails if statement always returns true
controller code:
def create
if current_user.id != params[:friend_id]
@return = { :curr_user_id => current_user.id, :params_id => params[:friend_id], :debug => 1 }
else
...
0
votes
2answers
81 views
Conditional Validations based on hidden_field_tag
In my form I use:
<%= hidden_field_tag :formtemplate, "newuser" %>
Based on this condition I want to validate in my model:
validates_format_of :email, :supervisor, :with => ...
0
votes
1answer
52 views
Validation condition on friendships in Rails 3?
I am writing my social network. I use devise as an authentication system. I used Self-Referential Association in railscasts. I want to solve my little problem that, I let users see the others profile ...
0
votes
1answer
77 views
Is it possible to “dynamically” join a table only if that table is not joined yet?
I am using Ruby on Rails 3.2.2 and I would like to know if in scope methods it is possible to "dynamically" join a table only if that table is not joined yet. That it, I have:
def ...
0
votes
3answers
76 views
Only calling a method if a hash is populated
I have an instance variable called
@filtered_ratings = params[:ratings].keys
However, if params[:ratings] is nil and #keys is called on it there is an error that is raised. If @filtered_ratings ...
0
votes
0answers
684 views
Rails view conditionally checked checkboxes are not checked, even though condition evaluates to true
I have a view where besides other things, checkboxes in a form are created dynamically (working), and when the form is submitted, the controller gives me back the same view with the content filtered ...
0
votes
0answers
392 views
Conditional Validation and Checkbox default value
I have a little problem with a conditional validation.
After some research and a Railscast i am still not sure what the problem is. Unfortunately is this my first time dealing with them so i can't be ...
0
votes
1answer
384 views
Rails conditional validation of Zip Code for many countries
I need a model-level validation for Zip codes in USA and Canada. This code makes me feel bad:
zip_regex_usa = %r{\d{5}(-\d{4})?}
zip_regex_canada = %r{[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d}
...