ruby-on-rails-3

Rails gives NameError for all command line methods such as generate or rake

浪子不回头ぞ 提交于 2019-12-24 11:29:20
问题 I'm a beginner with Rails and I've been trying to find out what in the world is going wrong here for the past few days but with absolutely no luck. I searched everywhere, but found nothing. Basically, when I run any sort of command line method, I will get a NameError. I have tried running this in different project directories as well that used to work. It seems that rails is just broken... I am running Win7-32bit using NetBeans 6.9.1 for editing files and cmd.exe for running rails console.

Delayed job not executed despite disappearing from delayed_jobs table immediately

≯℡__Kan透↙ 提交于 2019-12-24 11:28:35
问题 I implemented a delayed job in my Rails application, following the instructions. I start the Rails app I click on a link that launches the delayed job The job is visible in the database's delayed_jobs table I run rake jobs:work The job disappears from the table, so I guess the job has been performed BUT PROBLEM: /tmp/job.log has not been written (what the job should have done) The job: class CsvImportJob def perform File.open('/tmp/job.log', 'w') {|f| f.write("Hello") } end end The call: job

Rails: Paperclip with multiple placeholder images?

左心房为你撑大大i 提交于 2019-12-24 11:28:11
问题 I've been trying to experiment with having avatars for users in my app, and I've set this up where a user can upload an image using Paperclip. Paperclip has a nice default functionality where you can define a placeholder image when the user has not uploaded an image. What I'm wondering is, is there any way to create a set of placeholder images and have paperclip choose one at random when the associated record is created? IE so not all the "no avatar" icons have to be identical? Thanks! 回答1:

Can't use postgres user in new database for rails 3 on ubuntu 10.04 server

佐手、 提交于 2019-12-24 11:27:03
问题 I'm trying to get a rails 3 app up and running on an ubuntu 10.04. It's my first postgres project and i'm struggling to get postgres working properly. It's all installed, and i can get into it with psql . I followed the instructions here to set the password for the postgres user called 'postgres': #on the command line sudo -u postgres psql postgres #in postgres \password postgres \quit I thought that this would set the password for the postgres user to 'postgres'. But, now i can't log in as

Image and print_media_type for pdfkit are not working on rails 4.0.2

走远了吗. 提交于 2019-12-24 11:25:06
问题 I have created a pdf using pdfkit.Pdf is created. But the image is not displaying on my pdf and the print_media_type is also not working. I am using rails 4.0.2 and ruby 2.0.0. can anyone please help me to solve this problem? I am attaching details here. Thank you. gem file: gem 'pdfkit','0.5.2' gem 'wkhtmltopdf-binary','0.9.9.1' gem 'wkhtmltopdf-heroku','1.0.0' application.css : @media print { body { text-align: justify; font-size:566px; background-color: red; } } application.rb: require

customize kaminari pagination template

拟墨画扇 提交于 2019-12-24 11:20:43
问题 I'm having difficulty customizing the default kaminari template. I've used the generator to create kaminari template files. In kaminari/paginator.html.haml: = paginator.render do %nav.pagination All I want to do is access the actionview helpers within this, like link_to, or render. I've searched the source code and I can't find any incline of the helper being passed to this render method. Essentially, being able to do this: = paginator.render do %nav.pagination = render :partial => 'custom

rails 3- Having Action in Controller Without View

天涯浪子 提交于 2019-12-24 11:15:32
问题 I'm a complete Rails newbie and I have a Rails Question about controllers and actions. In my controller, I have an action named vote. The code is as follows. def vote @item = Item.find(params[:id]) @item.increment(:votes) @item.save render :action => show end I have a button on a "show" view that activates this action as follows <%= button_to "Vote", :action => "vote", :id => @item.id, %> My issue is that when the button is pressed, I don't want the application to try going to /items/:id/vote

Editing a gem definition on HEROKU (opentok)

℡╲_俬逩灬. 提交于 2019-12-24 11:15:04
问题 quick question about Heroku. My app is using a gem called opentok. To function outside of a "sandbox" mode, the app requires changing an API link in a gem file called opentok.rb. I did that locally and the app works fine. however, when I deploy to heroku, the app does not work because heroku looks at my gem file and gets the unmodified gem lib of opentok which then runs my app on the heroku server in sandbox mode. Is there a way I can access the opentok gem file (opentok.rb) on the heroku

How to display RoR app code version on heroku?

微笑、不失礼 提交于 2019-12-24 11:08:24
问题 For my Rails apps I normally deploy to production from a tagged version, and then display the tag in the user interface assigning the output of git describe --always to a variable in config/application.rb . Now I'm moving an app over to Heroku, and deployment to heroku only happens using the master branch, so this trick won't work any more. Are there any other ways to assign a version number to my code and display it on the UI when I've deployed to heroku? Thanks, Stewart 回答1: You can add a

How to set “programmatically”\“iteratively” each class object attribute to a value?

北战南征 提交于 2019-12-24 11:03:17
问题 I am using Ruby on Rails 3.0.9 and RSpec 2. I am trying to refactoring some spec file in the following way (in order to test with less code similar class object attribute values): [ :attribute_a, :attribute_b, :attribute_c ].each do |attr| before do # HERE I would like to set the "current" 'attr' related to the # class object instance 'attribute_< letter >' (read below for # more information) each time the iterator is called (note: all # following attributes are NOT attr_accesible - for that