ruby-on-rails

Bundler can't find win32-service gem even thought it appears in gem list

I'm trying to use bundler in a 2.3.4 rails app and am having problems with the win32-service gem. The gem was installed by issueing 'gem install win32-service --platform mswin32'. I installed it outside of bundler as bundler always tries to compile from source which fails miserably. Output of 'gem list' win32-service (0.7.1 x86-mswin32...

Does Agile Web Development With Ruby on Rails (Third Edition) Create Bad Coding Habits?

Does Agile Web Development With Ruby on Rails (Third Edition) teach best practices as well as Rails coding? My concern is that, as I use this book, I'm developing bad Rails coding habits resulting from the rather basic nature of the examples used in the book. Case-in-point: The Product Model: class Product < ActiveRecord::Base def s...

Why Ruby on Rails' Enumerable shows count of 3 but ".each" prints out item 1 time only

I have a Enumerable object returned from Mongoid (MongoDB object mapper) using HAML: = @employees.count = @employees.class - @employees.each do |e| =h e.inspect the count shows 3 the class shows Enumerable::Enumerator But only 1 item is printed out the object is returned in the controller using @employees = Employee.limit...

Trace source of deprecation warnings in rails tests

When running my functional tests, I'm getting the following warning in one of the test cases but I can't pinpoint where it's coming from: gems/actionpack-2.3.8/lib/action_controller/record_identifier.rb:76: warning: Object#id will be deprecated; use Object#object_id Unfortunately that's the only line of the backtrace that's shown, even...

In Rails 3, respond_to and format.all works differently than Rails 2?

the code respond_to do |format| format.html format.json { render :json => @switches } format.xml { render :xml => @switches.to_xml } format.all { render :text => "only HTML, XML, and JSON format are supported at the moment." } end the above will work in Rails 2.2.2. But in Rails 3, getting controller/index.html or index on th...

Rails 3 Scaffolding, Adding Routes Question

Hello, rails 3 newbie, with a general question about adding an additional route after scaffolding. I create a scaffold for books... Which works great, and provides a nice index page. The Index page shows all books in the system, I'd like to add a page '/books/yours' that shows the books the user created. I already added the user_id to...

Show latest posts all from unique tags (Rails 3.0, Acts_As_Taggable_On)

tags_controller.rb: def index @title = "tags" @posts = Post.tag_counts.collect do |tag| Post.tagged_with(tag).first(:order => "updated_at DESC") end @posts.uniq! end tags/index.html.rb: <%= render 'latest' %> _latest.html.erb: <%- for post in @posts -%> <%- post.tags.each do |t| -%> <%= link_to t.name, tag_path(t...

Threaded Comments - undefined method `children' for WillPaginate

Hello, The following problem has been fixed, I added an 's' to the end of comments, when it should just be comment, but a new problem has arisen at the bottom of this post. I am trying to get threaded comments for my already existing comments system by following the answer to this man's question: http://stackoverflow.com/questions/46393...

Access Object Attributes using Symbols

I have this helper that I am building: def myhelper(object, attributes = []) attributes.each do |attr| object.attr end end I invoke this helper using: myhelper Person, [:title, :name] What I am trying to achieve is to print a list of attributes in Person dynamically but object.attr in myhelper method won't work. How can I ...

Rails or Django style routing in Perl

I have grown accustomed to the way Rails maps a route or the Django uses regex on a route (I am not expect in Django, but this is what I have heard how it does it's routing) and how they use the style of permalinks to access a particle web page. Is it possible to do the same thing in Perl? ...

how get all routes in my rails application?

Sorry for my english. can I get all routes in my rails application? I need an output like rake routes and put the result in an array. Is it possible?, how? Thanks! ...

Rails Unit Test Issue with rake

Hey guys, I am working on writing tests for a rails 2.3.4 application and I am running into the following error when I try to run the tests 1) Failure: default_test(ReportTest) [rake (0.8.7) lib/rake/rake_test_loader.rb:5]: No tests were specified. This is what the only test file looks like: require File.dirname(__FILE__) + '/../test...

Which plugins/gems should I use to dynamically generate thumbnails on-the-fly in Rails 3?

So, the thing is. I'm building my first rails app which reads images from a directory and it's subdirs. Now, I want to generate dynamic thumbnails of those images. But I don't want to fill up that directory with the thumbnail images. I was thinking of caching these thumbs separately for each user in temporary directory. Oh, and, I would...

Get a member URL action with ActiveResource

I have a route in my application that is like this: /deployments/:id/logs.json It is used to retrieve logs for a specific deployment. On my client code, based in ActiveResource I have this: logs = Deployment.find(deployment.id).get(:logs, opts) Where opts is some parameters that I send via query string. The problem with this code...

What does this default RSpec statement mean?

User.should_receive(:update_attributes).with({'these' => 'params'}) What does that statement mean? these isn't instantiated anywhere as meaning anything. The whole statement is this : describe "with valid params" do it "updates the requested user" do User.should_receive(:find).with("37") { mock_user } User.should_re...

amazon-product-advertising-api gem + Rails 3

Does the amazon-product-advertsing-api gem work with rails 3? ...

Struts vs. [j]Ruby on Rails

I've spent the last 9 months using Ruby on Rails exclusively. I've been asked to join project and they are currently using Struts with Tomcat. I've done Java in the past and vowed never to go back for several reasons. They are currently having trouble finding people who know Java or are willing to join a project that uses it. (This is w...

Simple posts / comments route in rails 3

I'm trying to write a route that captures the one-to-many relationship between posts and comments in your average blog What I have currently is a post.rb class Post < ActiveRecord::Base has_many :comments end followed by a comment.rb (among all the other db setups including post_id:integer for comment) class Comment < ActiveRecord...

What testing frameworks are used for Rails?

I am new to rails, but not to ruby, and the book I am reading (Pragmatic Programmers Agile Dev. with Rails 4th Ed.) just introduced me to unit tests in Rails. The book showed me the default rails testing suite (a subclass of Test::Unit). In the Rails community, is this the main testing framework that is used, because I use RSpec when doi...

In rails 3 and rspec 2, how can I test the layout used by a call to render() ?

I'm trying to test that a view was rendered with a given layout. How can I test which layout was used for the call to render() ? ...