ruby-on-rails-3.1

Rails 3.1 Use an image without fingerprint hash

心不动则不痛 提交于 2019-12-06 12:30:34
I have solved a few of my asset pipeline woes, but one of them remains. I have a couple of image_tags, and I want them to refer to the non-fingerprinted/hashed/digested version. Is there a way to force an image_tag (but only one or two, not application-wide) to use the non-digested version of the image? Take a look at fingerprintless , that should do it. Use :digest => false as an option to asset_path within image_tag <%= image_tag(asset_path("filename.png", :digest => false)) %> 来源: https://stackoverflow.com/questions/9299724/rails-3-1-use-an-image-without-fingerprint-hash

Rails associations - how can I set up associations for different varieties of users?

旧城冷巷雨未停 提交于 2019-12-06 12:18:58
问题 I'm creating a web app which consists of schools, courses, students, and teachers. A school can have many courses and a course has one teacher and many students. The problem I am running into is that a single user could be a teacher of one course, but a student in another course (or even a student or teacher in a course in a different school). I don't want to create a model for teachers and a separate model for students because I would like to track all my users in one place. There is an

Rails 3.1 and Twitter Bootstrap modal don't play nice?

筅森魡賤 提交于 2019-12-06 11:18:55
I'm tearing my hair out over this one: I'm trying to use the Twitter Bootstrap modal (v.1, not 2) to post comments via AJAX, using the standard TB modal attributes for the div: <div class="modal hide fade" id="commentModal"> <div class="modal-header"> <a href="#" class="close">×</a> <h3>Say Something</h3> </div> <div class="modal-body"> <%= render 'common/error_messages', :target => @comment %> <%= form_for [@commentable, Comment.new], :remote => true do |f| %> <%= f.hidden_field :user_id, :value => current_user.id %> <%= f.text_area :content, :size => "84x5" %> </div> <div class="modal-footer

Turning a calendar into a form using Rails?

江枫思渺然 提交于 2019-12-06 11:04:38
Question : How do I turn a calendar into a form where the dateselect is rendered to match the calendar day instead of the current date? What I'm trying to do: I'd like to create a calendar that displays the cyclist's workouts. Create workouts within each calendar day, automatically rendering the workoutdate that matches the given day in the form Each workout has many intervals. Each calendar day has one workout. Plugins: Extracted the table_builder.rb and calendar_helper.rb from https://github.com/p8/table_builder (both gem and plugin do not deploy with rails 3.1) class WorkoutsController.rb

Rails 3 - DB seed data validation

人盡茶涼 提交于 2019-12-06 09:32:37
I am seeding a test database in Rails 3.1 through thousands of create calls in the seeds.rb file. A little problem arises when these calls do not pass the model validations: rails will not notify me this, and the seeding goes on correctly until the end of the file. At the end of the process I do not know which records have been created and which aren't, unless I check them one by one ... Is there a way to get notified when records do not pass validations when using rake db:seed or rake db:reset ? Thank you! You can create validations you want in the Models and use ModelName.create! . This will

form multiple select

浪子不回头ぞ 提交于 2019-12-06 08:39:57
I am learning rails and have been struggling with this for over a day now and can not figure out how to get this to work. I want a select box in my form that can select multiple elements. I have this working with this code: <div class="field"> <%= f.label :products %><br /> <%= f.select :products, {"A"=>1, "B"=>2, "C"=>3, "D"=>4},{},:size=>5,:multiple=>true %> </div> This works fine and produces this HTML: <div class="field"> <label for="script_products">Products</label><br /> <select id="script_products" multiple="multiple" name="script[products][]" size="5"> <option value="1">A</option>

Huge json object to excel?

白昼怎懂夜的黑 提交于 2019-12-06 08:05:21
I have a PHP application which has a table with more then 10000 rows and I am trying to export that into an excel sheet via my ROR application but my request is getting timed out on the server by PHP application.So I was wondering is there any elegant way to solve this problem. I come up with 2 solutions. First is doing a batch processing (need to read about as I am new with it) and the other is that my php application will send a large json object and my ruby app will read that json object write the data to excel sheet and sends back the excel sheet.So I wanted to ask whether is there any

How to swap jquery for prototype in Rails 3.1

送分小仙女□ 提交于 2019-12-06 07:52:39
I have a rails 3.1 project that was created with the default jQuery. What is the best way to convert the project to use prototype instead? Remove the jquery gem from Gemfile add prototype-rails to it From https://github.com/rails/prototype-rails : You may want to add them to your app/assets/javascripts/application.js: //= require prototype //= require prototype_ujs //= require effects //= require dragdrop //= require controls New applications using this may also want to add config.action_view.debug_rjs = true to their config/environments/development.rb. diodeus is right, i'd rewrite it, and

therubyracer fails to build on heroku

走远了吗. 提交于 2019-12-06 07:42:53
I've made a Rails 3.1 PoC application that also uses haml by adapting the examples from the railstutorial.org book and locally everything works fine. But when I try to push to heroku , therubyracer fails to build on the server ( full output ) : Installing therubyracer (0.8.2) with native extensions /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) My Gemfile is pretty standard, so I would really appreciate if somebody could help me understand what's going wrong, and maybe

Ruby on Rails 3: How can I sort ActiveRecords by an attribute of another table?

二次信任 提交于 2019-12-06 07:30:26
I need to query a database table and get the rows ordered by a count of an association. Is there a Rails (like Active Record Query) way to do this? My models and their associations are as follows: class User < ActiveRecord::Base has_one :business end class Business < ActiveRecord::Base has_many :postulations end class Postulation < ActiveRecord::Base belongs_to :business end I need to get a number of Users ordered by the amount of Postulations that their Business has. Is there a clean way to do this or do I just have to query with find_by_sql? Thank you. User.includes(:business =>