I'm trying to connect to an API and retrieve the json results with my rails app, however it doesn't seem to work.
Take for example:
@request = Net::HTTP::Get.new "http://example.com/?search=thing&format=json"
When I try the url in my browser it works! and I get JSON data, however when I try that in Ruby the body is nil.
>> y @re...
Hello, I want to add a admin functionality to my webapp with Rails version 3. I want something very simple, there will be only one admin, this funcionality doesn't need a username field, just a password field. I don't know how to do it, can you help me?
Thanks!
...
When trying Hpricot and Nokogiri, the HTML can be fetched and parsed, but can they also execute the Javascript as well so that the content shows on the page? (shows up in the the DOM). That's because some page won't show the info unless the Javascript interpreter has run.
...
I am using this named_scope to search for products that have a description matching any word the user inputs.
E.g., Product.description_like_any("choc pret")
Will return products with names like
"Chocolate Bar"
"Chocolate Covered Pretzels"
"Miniature Chocolate Ponies"
Here's the named_scope I've written (which works)
named_scope :...
Hi.
Is there such thing? I didn't find any :(
...
I have a table like:
+--------+-----------+-------+-----------+
|house_no|house_alpha|flat_no|street_name|
+--------+-----------+-------+-----------+
| 1| | |James St |
| 1| | |James St |
| 1| | |James St |
| 2| A| |James St |
| ...
Hi.
I installed the new stable Ruby release and when I began to install gems I found out that the paths to them isn't added to the Ruby load path after successful installation of the gems.
What is the reason of this issue? How can I achieve it?
Thanks.
Here's my environment:
$ lsb_release -d
Description: Debian GNU/Linux 5.0....
Trying to install the new Rails 3 release on OSX 10.6.
Have never touched Ruby or Rails on this machine since purchased.
I was able to get rvm and get Ruby 1.9.2. installed. From there, I am stuck.
I tried:
rvmsudo gem install rails -v 3.0.0
sudo gem install rails --pre
sudo gem install rails
sudo gem update rails
And I get the sam...
This may well be a duplicate, but I couldn't find anyone asking quite this question.
My understanding* is that if I want to migrate data from an outside source to my Rails app's database, I should do so using a migration. It seems from my preliminary research that what I could do is use a tool like FasterCSV to parse a CSV file (for exa...
Does anyone know the rules for valid Ruby variable names? Can it be matched using a RegEx?
UPDATE: This is what I could come up with so far:
^[_a-z][a-zA-Z0-9_]+$
Does this seem right?
...
This is what I'm doing
a = "%span.rockets#diamonds.ribbons.forever"
a = a.match(/(^\%\w+)([\.|\#]\w+)+/)
puts a.inspect
This is what I get
#<MatchData "%span.rockets#diamonds.ribbons.forever" 1:"%span" 2:".forever">
This is what I want
#<MatchData "%span.rockets#diamonds.ribbons.forever" 1:"%span" 2:".rockets" 3:".#diamonds" 4:".r...
Are there good tutorials on how to use rdoc:
how to comment the source code
how to generate documentation
how to put it online
I cannot find any good information for this.
...
Since Windows doesn't support rvm (Ruby version Manager), how do we have
Ruby 1.8.7, Rails 2.3.8
Ruby 1.8.7, Rails 3.0.0
Ruby 1.9.2, Rails 3.0.0
on the same PC? Virtual machines can be used but it is kind of troublesome.
...
More and more people just say Rails instead of Ruby on Rails nowadays... and isn't it Rails, which is developed on top of Ruby, so it is really Rails on Ruby?
Update: when people say: I am using Rails, that means it is Rails they are using. When people say: I am using Ruby on Rails, that means they are using Ruby that happens to be on ...
I have a log file, most lines are quoted at first and last character, like:
"2010-09-09,13:33,"user logoff",0"
What's the ruby regex to remove the head and tail quotation marks? so the result string looks like:
2010-09-09,13:33,"user logoff",0
...
Hi guys,
I cannot install thin gem on windows. Something happen during build of native extensions.
Do anybody face same issues?
Here is the stack trace:
>gem install thin --no-ri --no-rdoc
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing thin:
ER...
Are there any differences between the following ways of initialization of variables?
@var ||= []
@var = [] if @var.nil?
@var = @var || []
Please share your way initializing a variable and state the pros & cons.
...
I've seen Ruby code in which there are only two double quotes ("") on a line. What does that line do?
...
hi , i am new to ROR
i was acually trying to write Ruby code for the api blogs
i have written the ruby code as
Loading development environment (Rails 2.3.8)
>> class Blogpost < ActiveRecord::Base
>> has_many :taggings
>> has_many :tags,:through => :taggings
>> end
=> nil
>> class Taggings < ActiveRecord::Base
>> belongs_...
I have two sites, my main site and a help site with documentation. The main site is rails but the other is simple a wordpress like blog. Currently I have it being pulled into the main site with an iframe, but is there a good way to pull in the html from the other site as some sort of cross-domain (sub-domain actually) partial? Or shou...