I have many products, each product belong to one category.
How can I generate each category in hyper text, and when I click on the category hyper text, I can get all the products which is belongs to this category. And ideas on that?
...
Hello!
At the moment I try to do following:
I created several partials (i.e. _show_signature.html.erb) for my user.
Now I want to show them on clicking a link.
In my user controller, I created a new action:
def show_signature
@is_on_show_signature = true
end
def show_information
@is_on_show_information = true
end
...
What I'm doing is this: have one file as input, another as output. I chose a random line in the input, put it in the output, and then delete it.
Now, I've iterated over the file and am on the line I want. I've copied it to the output file. Is there a way to delete it? I'm doing something like this:
for i in 0..number_of_lines_to_remov...
For test purposes I want to change the return value of request.remote_ip. While being on my development machine it returns always 127.0.0.1 as it should but I would like to give myself different fake IPs to test the correct behavior of my app without deploying it to an live server first!
Thank you.
...
While trying to brush up my Ruby skills I keep running across this case which I can't figure out an explanation for by just reading the API docs. An explanation would be greatly appreciated. Here's the example code:
for name in [ :new, :create, :destroy ]
define_method("test_#{name}") do
puts name
end
end
What I want/expect to...
In Ruby, I want to store some stuff in a Hash, but I don't want it to be case-sensitive. So for example:
h = Hash.new
h["HELLO"] = 7
puts h["hello"]
This should output 7, even though the case is different. Can I just override the equality method of the hash or something similar?
Thanks.
...
So as I understand it, the === operator tests to see if the RHS object is a member of the LHS object. That makes sense. But how does this work in Ruby? I'm looking at the Ruby docs and I only see === defined in Object, I don't see it in Integer itself. Is it just not documented?
...
In Episode 78 of the Joel & Jeff podcast one of the Doctype / Litmus guys states that you would never want to build a spider in ruby. Would anyone like to guess at his reasoning for this?
...
I'm using the sample extjs status bar, the one with the word count demo. I set the name and id of the text area within my JS file to match the other form items on the page (in this case something like, user_description and user[description]) However when it throws back an error with validation of the description being over my limit, it "...
I am a ruby beginner. From the book, I know that ruby method name should start with a lowercase letter ( or underscore). But I found different scenarios:
if a method is defined outside a class, it can only begin with lowercase letter, Ruby will complain error if you try to define a method which begin with uppercase letter, for example...
When using Eventmachine to asynchronously execute an HTTP request, either by using em-http-request or some other means, is it possible to get information about the error in the errback callback? Like connection error vs. timeout vs. invalid response?
...
I'm building my Rails template right now. Rails template is a way to generate
a skeleton app.
http://railscasts.com/episodes/148-app-templates-in-rails-2-3
http://m.onkey.org/2008/12/4/rails-templates
I would like to add some gems to test.rb and development.rb, but not environment.rb.
But I don't find a way to do so other than manua...
According to (somewhat official) this guide, I can make a radio button's label make the selection for that radio button too. They say,
Always use labels for each checkbox and radio button. They associate text with a specific option and provide a larger clickable region.
Unfortunately, I have not been able to get this functionality...
Dear Colleagues
I am a newie in Ruby and I am facing a problem regarding "each"-like loops. Suppose a code like the following
startIndex = 1
endIndex = 200
(startIndex..endIndex).each do |value|
p value
if value>150 then endIndex=100
end
When I run the code it will run until 200, not until 150. Is there any way to change the l...
How do I do this type of for loop in Ruby?
for(int i=0; i<array.length; i++) {
}
...
Can I use stored procedures with ruby on rails ?
I am using mysql as database and ruby on rails.
please provide me any of the example for this.
...
I am somewhat of a Rails newbie so bear with me, I have most of the application figured out except for this one part.
...
What's the more accepted Rails approach?
Validate that a foreign key exists on creation/update
or
"Damage control" when we want to use the non-existent foreign key?
Initial validation requires more resources on row creation/updating, and may even be redundant when I'm creating rows systematically in my code (i.e. not user generated)....
The hash method on a Ruby String returns a number based on the string's length and content:
>> "foo".hash
=> 876516207
What's the equivalent in Perl?
...
Hi,
I am trying to tell ruby to not run a block of html and ruby if no active record exists in the database. Below is the code I was trying to run conditions on.
<% if @statemant.comments.exists?() do %>
<div id="comments">
<h2>Comments</h2>
<%= render :partial => @statemant.comments %>
</div>
<% end %>
...