ruby-on-rails-3.1

Rails: How to disable asterisk on form's required fields?

邮差的信 提交于 2019-11-27 05:35:31
问题 When I add the 'Required' attribute to html input fields, Rails pre-pends an asterisk (*) before the label. Does anyone know how to prevent this? For some reason Rails transforms this: <%= f.input :Company, :input_html => {:value => "", :id => "company_name"}, :label => "company name" %> into this: <div class="input string required"> <label for="company_name" class="string required"> <abbr title="required">*</abbr> company name</label> <input type="text" value="" size="50" required="required"

Devise redirect after confirmation

被刻印的时光 ゝ 提交于 2019-11-27 05:18:46
问题 How can I create an after confirmation redirect in devise? Before I added the confirmation module the custom after_sign_up_path worked fine for the first time login/signup but now when I click the confirmation link in the email it redirects to the path i set for the after login path (user profile). My goal here is to create a form wizard and "getting started" page to collect additional information. The obvious caveat being that this redirect will only happen 1 time, upon confirmation. I have

Error while loading shared libraries: 'libpcre.so.0: cannot open shared object file: No such file or directory'

房东的猫 提交于 2019-11-27 05:17:43
问题 I just installed Passenger 3.0.11 and nginx and got this error: Starting nginx: /opt/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory 回答1: The message means what it says. The nginx executable was compiled to expect the PCRE (Perl-compatible Regular Expression) shared library to be available somewhere on LD_LIBRARY_PATH or specified in /etc/ld.so.conf or whatever equivalent library-locating mechanisms apply to your

Clear the cache from the Rails asset pipeline

独自空忆成欢 提交于 2019-11-27 05:10:18
问题 I'm starting a new project in Rails, and it looks like the application.js manifest file is doing something funny with the javascripts that I reference - does it cache those files as part of the asset pipeline? Here's what happened. I added a javascript file named jquery.autoresize.js to the vendor/assets/javascripts folder, and then referenced the file in the application.js manifest like this: //= require jquery.autoresize.js Then I started up the rails server. But after navigating around in

Testing Rails 3.1 mountable engine with Rspec

試著忘記壹切 提交于 2019-11-27 05:06:07
问题 I started making a Rails 3.1 engine, and I'm having a hard time testing it using rspec. First of all, if I run rails g integration_test whatever it creates a regular integration test in tests/integration instead of spec/requests (the rspec-rails gem is installed and required as a development dependency in the gemspec file) Also, when I run a spec test I get an error saying the table corresponding to the model I'm testing has not been created. I tried rake engine_name:install:migrations and

skip certain validation method in Model

老子叫甜甜 提交于 2019-11-27 04:23:13
问题 I am using Rails v2.3 If I have a model : class car < ActiveRecord::Base validate :method_1, :method_2, :method_3 ... # custom validation methods def method_1 ... end def method_2 ... end def method_3 ... end end As you see above, I have 3 custom validation methods , and I use them for model validation. If I have another method in this model class which save an new instance of the model like following: # "flag" here is NOT a DB based attribute def save_special_car flag new_car=Car.new(...)

Rails 3.1: Better way to expose an engine's helper within the client app

自闭症网瘾萝莉.ら 提交于 2019-11-27 04:22:05
问题 I have found a few articles addressing the issue of helpers within an engine not being accessible to the consuming (parent) application. To make sure we are all on the same page, let's say we have this: module MyEngine module ImportantHelper def some_important_helper ...do something important... end end end If you look at the rails engine documentation in the "Isolated engine's helpers" (L293), it says: # Sometimes you may want to isolate engine, but use helpers that are defined for it. # If

Rails 3.2, FATAL: Peer authentication failed for user (PG::Error)

隐身守侯 提交于 2019-11-27 04:08:39
问题 I am running my development on Ubuntu 11.10, and RubyMine Here is my development settings for the database.yml: which RubyMine created for me development: adapter: postgresql encoding: unicode database: mydb_development pool: 5 username: myuser password: when I try to run the app, I get this error below, it seems that I didn't create a 'project' user yet, but, how can I create a user and grant it a database in postgres ? if this is the problem, then, what is the recommended tool to use in

what is the difference between link_to, redirect_to, and render?

…衆ロ難τιáo~ 提交于 2019-11-27 02:08:55
问题 I am confused about the main difference(s) among link_to , redirect_to and render in Rails. anyone can please explain. 回答1: link_to is used in your view, and generates html code for a link <%= link_to "Google", "http://google.com" %> This will generate in your view the following html <a href="http://google.com">Google</a> redirect_to and render are used in your controller to reply to a request. redirect_to will simply redirect the request to a new URL, if in your controller you add redirect

Convert HTML to word file ?

一笑奈何 提交于 2019-11-27 02:03:15
How to convert ruby file in word file i.e (docx file). For pdf, we prawn gem. But is there any gem for word file. I am trying to convert my html file in word file so that it can be editable for user too. What should do in that case ? I was planning to convert that file in word file. Will it be possible or not. If you are using Rails: in initializers/mime_types.rb: Mime::Type.register 'application/vnd.ms-word', :msword in your controller: say you want to export show action: def show @item = Item.find params[:id] respond_to do |format| format.html # show.html.erb format.xml { render :xml =>