How do I make an HTTP GET request with parameters in Ruby?
It's easy to do when you're POSTing:
require 'net/http'
require 'uri'
HTTP.post_form URI.parse('http://www.example.com/search.cgi'),
{ "q" => "ruby", "max" => "50" }
But I see now way of passing GET parameters as a hash using net/http.
...
In a view that I have, I am using fields_for to display form data for a relational table. However, part of this form will have select lists to choose from. I see there are label, text_field, text_area helpers for the form_for and fields_for helpers that will fill in the info needed from an already populated model object... but what abo...
Here's an excerpt from a fairly standard Rails form:
<p>
<%= f.label :from_station %> <%= f.text_field :from_station %>
</p>
<p>
<%= f.label :to_station %> <%= f.text_field :to_station %>
</p>
By default, this renders like this:
This doesn't look great since the text fields don't line up. What's the easiest way to m...
I've been trying to make my rails create URLs to show records by using their title instead of their ID in URL such as:
/posts/a-post-about-rockets
Following a tutorial online I did the following:
Because the ID is no longer in the URL, we have to change the code a bit.
class Post < ActiveRecord::Base
before_create :create_slug
...
Hey guys,
I am wondering how I can go about using the Zimbra API. I have looked everywhere for an API, and I have found no good references/tutorials about it.
I have a web application that I have developed in Ruby on Rails that I would like to communicate to Zimbra in order to fetch the calendar items to put in my own Calendar interf...
Hi all,
I'm trying to implement a Dashboard using Abobe Flex which is fed from a Ruby on Rails application. The Dashboard will just display charts and tables which can be fed by JSON, XML etc. feeds.
A User will need to login into the Flex frontend before they can view the Dashboard, so I have two main requirements for this to work:
1...
I have a rails app I created with based on a DB with a table named "countries", which stored a list of all the countries in the world. Now I have found out that the actual DB I will be using uses a table named "ctry" instead (stupid I know). What I am trying to figure out is if there is any way I can point active record to this new table...
Can anyone tell me what is the difference between build and new command on Rails?
...
What is the best approach in order to localize images (buttons and other content) in a i18n rails app?
...
Hi all.
Could you plz explain me how to correct this problem. I've installed rails edge on perfect working with 2.3.3 application and on attempt to launch server i've got (ruby 1.8.6)
$ ruby script/server
=> Booting Mongrel
=> Rails 3.0.pre application starting on http://0.0.0.0:3000
/Library/Ruby/Site/1.8/rubygems.rb:270:in `activate':...
We recently had an issue I'd never seen before, where, for about 3 hours, one of our Mysql tables got extremely slow. This table holds forum posts, and currently has about one million rows in it. The query that became slow was a very common one in our application:
SELECT * FROM `posts` WHERE (`posts`.forum_id = 1) ORDER BY posts.crea...
hi all,
i am newbie in rails and try to perform left join in mysql.
there are two objects - user and message.
user has_and_belongs_to_many messages, message has_and_belongs_to_many users
currently, by simply writing user.messages i get following query in console
SELECT * FROM `messages` INNER JOIN `messages_users` ON `messages`.id ...
Can any one please help to how to fetch the values of attributes from the has_many Relationship on rails
For example
company is one relation and has many email
company --> email
i need to fetch email_address from those company.email
How can i do that?
company.email.email_address
...
I tried using ActiveResource to parse a web service that was more like a HTML document and I kept getting a 404 error.
Do I need to use an XML parser for this task instead of ActiveResource?
My guess is that ActiveResource is only useful if you are consuming data from another Rails app and the XML data is easily translatable to a Rail...
e.g.: comma seperated in a single textfield: [email protected], mail2@someotherdomain, ...
...
After reading the book RESTful Web Services by Leonard Richardson and Sam Ruby, it seems to me, that the to_xml method of rails is not as restful as it should be. Specifically, the book introduces the Resource Oriented Architecture, one of the tenets of which is connectedness: Representations of a resource should contain not only the dat...
Is anyone using Prawn / Prawnto with Jruby on rails? I installed prawn 0.5.01 and rails 2.3.2. I just installed prawn and prawnto and started playing with the PDF generation capabilities. I am concerned that the pranwto web site is no longer online - http://www.cracklabs.com/prawnto Is this rails plugin dead? Or has it moved somewhe...
Assume I have a named scope:
class Foo < ActiveRecord::Base
named_scope :bar, :conditions => 'some_field = 1'
end
This works great for queries and I have a bunch of useful named_scopes defined. What I would like is to be able to do this:
f = Foo.find(:first)
f.some_field = 1
f.is_bar? #=> true
The '.bar?' method will simply ret...
Integrating FB Connect into our site using Rails 2.2.2 and Facebooker gem (latest version). Login button, xd_receiver files generated fine to the point where the login popup window will open, I can log in, and it will then execute the onlogin event, but Facebooker's facebook_session method just keeps returning nil. Upon inspecting the se...
I have errors in a model that are showing up in the view when accessed with @model.errors. However, they do not show up if I try to do
<%form_for @applicant do |f|%>
<%=f.error_messages%>
This is zero, freakily: <%=f.error_messages.length%>
But this is not: <%[email protected]%>
however, the errors are p...