ruby-on-rails

Can't upload photo using paper clip...

I used paper clip in my web application, I use this to make a new product: <% semantic_form_for @product do |f| %> <% f.inputs do %> <%= f.input :title %> <%= f.input :price %> <%= f.file_field :photo %> <%= f.input :category , :include_blank => false %> <% end %> <%= f.buttons %> <% end %> And th...

Anybody using ruby without any framework?

I am experimenting with Ruby and Rails. I like Ruby, but not Rails. I have Java/PHP background, I have used some frameworks, but never totally liked any of them. Anybody using Ruby to build web apps, but not any of the frameworks? (rails, merb etc). If yes, can you point me to some resources to learn it? ...

Learning Rails: Create link to named route with only text in nested span

For the life of me, I can't figure out (or find the right text to search) how to create a link that looks like this: <a href="/publisher" class="button first"><span>This text will be hidden</span></a> There's a similar example in the link_to API, but it doesn't quite get to what I need. I don't want my anchor tag to have any text (all...

prepared statements in rails/activerecord

does rails activerecord have any support for prepared statements? best I can tell -no. ...

How do I cache ActiveRecord model objects across redirects?

This is possibly a newbie question, but I'm not sure what terms to search for. Say I have a CUSTOMER object, and I want to send a MESSAGE to that customer. What I would do first is add a SENDMESSAGE action on the CUSTOMER controller, which builds the message object. (Assume this is the right thing to do?) In this instance however, ra...

Postgresql not working with ruby on rails on mac os x

Hi, I just switched to mac, I was previously working on Linux. I am trying to use posgresql for my project When I start the server, it works fine. Nevertheless when I use rake:db:migrate, it fails saying: Please install the postgresql adapter: gem install activerecord-postgresql-adapter (no such file to load -- pg) I have the gem "pg...

Ruby on Rails: Creating child objects

I'm sure this is a very simple question, but I'm just a newbie so... I have a model, Game, which has_many :piles. Pile, in turn, has_many :cards. I'm able to populate the Piles and Cards at creation of the Game, so my code at present looks something like: class Game < ActiveRecord::Base has_many :piles def after_create 1.upto(...

Specify Cookie Domain in Authlogic When Session Is Created

Is it possible to set the cookie domain to something other than the current domain when a session is created with Authlogic? When a new account is created from our signup domain, I'd like to redirect the user to their subdomain account and log the user in. Current controller: def create @account = Account.new(params[:account]) if ...

Adding Children with awesome_nested_set in rails

How do I add children to a parent using the awesome_nested_set plugin? I have a model, Unit, which is a nested set. I'd like to add sub-units. Within the edit view, how I let the user add children (sub-units) to the parent (unit)? ...

Ruby Integer(), Array(), et al -- what are they? Where do they come from?

I've come across conversions of the form Array(value), String(value), and Integer(value) on occasion. It appears to me that these are just syntactic sugar for a call to the corresponding value.to_a, value.to_s, or value.to_i methods. So I'm wondering: Where/how are these are defined? I can't find them in Object, Module, Class, etc A...

What are the current resources for building a Facebook application with Rails?

I'm looking to build a basic Facebook application with Rails. What are the resources (books podcasts, screencasts, blog articles etc) that you'd recommend? (One answer per post please, and up-vote instead of duplicate). ...

RJS returns plain javascript without JS tags

Here is code on view in FeesController "show" action template: <div id="payers_controls"> <%= link_to_remote('New payer', :update => "payers_controls", :url => new_payer_url) %> </div> Here is new.rjs - belongs to PayersController "new" action page.replace_...

Web infastructure for learning purposes?

I come from a traditional programming background by which I mean C, Java, C#, C++ and a little python and VBA. Now I'm trying to create a small CRUD application for the purpose of taking a form and turning it into an online form and database for later querying. My initial thinking seems to lead me to Ruby on Rails given the fact that...

Rails - build_association is not working for a has_one and belongs_to relationship.

I have two models class Subscription < ActiveRecord::Base belongs_to :client end class Client < ActiveRecord::Base has_one :subscription end but when I try to create a parent from the child e.g. sub.build_client the foreign key does not get set e.g. >> sub = Subscription.new => #<Subscription id: nil, token: nil, user_id: nil, c...

How can I restrict Markdown syntax in Ruby?

I wish to implement Markdown in a Rails CMS comments system using a Ruby library such as Maraku or Kramdown. I need to restrict which Markdown features the users can submit. In this system users aren't allowed to insert to images, html, or perform any heavy editing, but emphasis and hyperlinks are okay. Essentially, I wish to create som...

Visualize Rails schema.rb with tool/plugin/script

I am looking for a tiny tool/script/plugin to visualize my Rails schema.rb file so that our project does not have to maintain a separate diagram manually. Do you have any experiences on that subject? ...

How can I create a web service using Ruby on Rails?

How can I create a web service using Ruby on Rails? Please give an example. ...

Specify host for Rails functional tests

Some of my controller actions use the request.host parameter in their logic. In integration tests I can use the host! method to set the host. How can the same be achieved in functional tests? ...

Reading a file in Rails Template

I'm making a Rails template file as introduced below: http://asciicasts.com/episodes/148-app-templates-in-rails-2-3 I have a big file I want to make, so instead of doing: file "bigfile.txt", <<-EOF content of the file... EOF I want to read the content from another file. What I have now is: file "public/stylesheets/sass/960.sass...

assert_response doesn't work with webrat in selenium mode

Anyone know how to get assert_response to work with webrat using selenium? I keep getting NoMethodError: undefined method `response_code' for nil:NilClass Here's my test: def test_basic_page_load visit root_path click_link "register" assert_response 200 end Here's the error: ==> Waiting for Selenium RC server on port 4444.....