ruby-on-rails3

Globalize3 breaks permalink_fu

Hi All, I'm trying to use permalink_fu with globalize3. I have has_permalink :name translate :name The problem is that it doesn't keep my permalinks unicity, If I create a Product named "Test" and then another one named "Test", they both will have the permalink "test" (the first should be 'test' and the 2nd should be 'test-2').. ...

rake tasks are not discovered in rails 3

Hi, I have trouble getting started with rails 3.0.0, because it just doesn't load the rake tasks rake gems:install rake aborted! Don't know how to build task 'gems:install' rake -T rake about # List versions of all Rails frameworks and the environment rake db:create # Create the database from config/database.ym...

rails3 is it possible to create a model.scope with no constraints

I am trying to create a scope on a model of mine limiting the available results to only those that are owned by the user's partner. When the user is an administrator, however, I want all models to be available. This works, but looks stupid. What is the proper rails3 way of expressing this? scope :accessible_by, proc { |user| if user.a...

Generators with rails 3 and rspec 2

I installed rails 3 with rspec 2, but when i run controller generator it creates rspec tests only for controller helpers and does not create them for controller itself. ...

OAuth Provider Service and Rails 3

I am trying to look into setting up an OAuth Provider Server with Rails 3 but can't seem to find anything out there to accomplish this. I am also a newb when it comes to oauth, so excuse my ignorance. When setting up an oauth server do I need to already have an oauth account at somewhere like agree2.com? Or can I just use my own serve...

In Rails 3's "rails runner", how do you use number_to_human_size() method?

In a rails console, it can be done this way: ree-1.8.7-2010.02 > helper.number_to_human_size 1 => "1 Byte" ree-1.8.7-2010.02 > helper.number_to_human_size 100000 => "97.7 KB" ree-1.8.7-2010.02 > helper.number_to_human_size 0 => "0 Bytes" ree-1.8.7-2010.02 > helper.number_to_human_size 100000000 => "95.4 MB" but what about in a...

Best way to add "current" class to nav in Rails 3

I have some static pages in a navigation menu. I want to add a class like "current" to the item which is currently displaying. The way I am doing so is to add tons of helper methods (each for one item) to check the controller and action. def current_root_class 'class="current"' if controller_name == "homepage" && action_name == "inde...

Extra params in Rails 3 routes and resources

The new rails routes are great in many aspects, but I am looking for the best way to achieve page caching with pages and formats like I had in rails 2.x and am coming up short I have many possible desired routes of the basic formulas: /(bazes/<baz id>/)(foos/<foo id>/)bars/page/<page num>/<format> Example routes: /bars/page/1/xml /f...

What's the alternative of :befor & :after of rails 2.3.* in Rails 3 ?

I am using remote form in Rails 3. It works fine but I want to show / hide spinner during ajax request. In rails 2.3.* we use :before & :after in remote form to show/hide spinner What should I do in Rails 3, as remote form of Rails 3 doesn't contain such options. ...

How to use the Rails 2.3 app generator when I have Rails 3 installed?

Hi, to clarify: there's only one rails command, which gets installed from the latest Rails gem, which is Rails 3 ATM. However, I'm required to create a Rails 2.3 app. Running ruby /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/bin/rails fails with a NoMethodError, I suppose because it also tries to use gems from the 3.0.0 release. Unin...

Rails: " Draggable_elements" not working inside table elements

Hello - We are trying to implement a functionality in our ROR application such that we are able to drag and drop rows between different tables. We tried using Scriptaculous Drag and Drop method but it does not works inside the table tags. Can you point us to other alternatives like JQuery etc which might be useful. Thanks Supreet ...

Rails i18n strings auto-lowercased?

Hi there, I've noticed that in my new Rails 3.0 application all German i18n strings are converted to lowercase (except for the first letter). When having a string like this: de: email: "E-Mail" the output is always like "E-mail". Same story with all the other strings - uppercase letters within a sentence are auto-converted to lowe...

Rails3, Cucumber, Capybara, File upload => bad content body (EOFError) ?

I'm having a hard time getting a simple file upload test working. I'm using Rails 3.0.0 on ruby 1.9.2 with Cucumber and Capybara. View: <%= form_tag "/upload/create", :multipart => true do %> <label for="file">File to Upload:</label> <%= file_field_tag "file" %> <%= submit_tag "Upload" %> <% end %> Cucumber Step: When /^I upl...

Configure Rails to use different js in development and production

Hi guys, I want Rails to inject different js files in development and production modes. Example: Development: <script src="/javascripts/jquery.js" type="text/javascript"></script> <script src="/javascripts/myscripts.js" type="text/javascript"></script> Production: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jque...

Roles that are User<>Project Based

Hello... Currently I'm using Devise & CanCan which allows me to create Users with Roles using a (Roles_Users) table. That's nice, but what I want is to Have Projects in my app and for each project for a user to possibly have a role like (Admin, Viewer, etc) IE, roles are not assigned to users but to users based on what projects the...

Rails 3 Server Startup problem with fastercsv

I have a rails 2.3.5 app getting upgraded to Rails 3. I did every thing I am required to do for upgrading and when I start the rails server using rails server it gives me this Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine. I am using ruby-1.9.2-p0 and have faster...

Learning how to spec..seem to be having troubles

Here's my code I'm spec'ing: def vote_up get_vote @vote.value += 1 unless @vote.value == 1 @vote.save respond_to do |format| format.js { render :action => "vote", :layout => false } end end Seems pretty straightforward. This is what I'm trying to spec it with : it "should vote up" do @mock_cat = Factory.create(:ca...

How to use javascript_include_tag to get all scripts in a folder

Hi guys, I'd like to use javascript_include_tag to grab all view related scripts using recursion, which a placed in public/javascripts/views. I'm trying javascript_include_tag "/views", :recursive => true, but failed to add any script. Regards, Alexey Zakharov ...

Which is the best place to set title in Rails ?

Before Rails 3 I used to set a title instance variable in my controller actions and then use <%=@title%> in my layouts. But in Rails 3 they have included a helper method def title(page_title) @content_for_title = page_title.to_s end and in the application.html erb <title><%= yield(:title) %></title> This requires us ...

Ununderstandable Rails 3.0 log

Hi, since i migrated to rails 3.0, logs are now filled with queries like this: SQL (8.5ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"checkins"'::regclass AND a.attnum > 0 AND NOT a.a...