ruby-on-rails-3.1

Rails 3.1 text_field form helper and jQuery datepicker date format

寵の児 提交于 2019-11-30 05:27:27
问题 I have a form field in my Rails view like this: <%= f.text_field :date, :class => "datepicker" %> A javascript function converts all input fields of that class to a jQueryUI datepicker. $(".datepicker").datepicker({ dateFormat : "dd MM yy", buttonImageOnly : true, buttonImage : "<%= asset_path('iconDatePicker.gif') %>", showOn : "both", changeMonth : true, changeYear : true, yearRange : "c-20:c+5" }) So far so good. I can edit the record and it persists the date correctly all the way to the

Rails 3.1 Deployment to Heroku Error

安稳与你 提交于 2019-11-30 05:14:46
I'm trying to deploy my app to Heroku, I've done this before on my Windows machine, and now I am currently using a mac. I'm trying to use Postgresql for the first time. I have the following in my Gemfile: gem 'pg' EDIT: AndrewDavis-OSX:lunchbox ardavis$ rvm list rvm rubies => ruby-1.9.2-p180 [ x86_64 ] AndrewDavis-OSX:lunchbox ardavis$ heroku rake db:migrate rake aborted! /app/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end App::Application.config.session_store :cookie_store, key: '_app_session' ^ (See full trace by running task with --trace) (in /app) As

Formastic Bootstrap Rails Error- No Such File to Load ButtonsHelpers

跟風遠走 提交于 2019-11-30 05:00:12
问题 I'm completely stuck on this error. Using Rails 3.1 trying to implement Formastic Bootstrap gem and getting error: `': no such file to load -- formtastic/helpers/buttons_helper (LoadError) Application.css *= require formtastic *= require formtastic-bootstrap Gemfile group :assets do gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem 'uglifier' gem 'less-rails-bootstrap' gem 'bootstrap-sass' end formastic.rb Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap:

Calling coffeescript functions from console

泪湿孤枕 提交于 2019-11-30 04:52:54
Playing a little with coffeescript and Rails 3.1.0.rc4. Have this code: yourMom = (location) -> console.log location yourMom "wuz hur" When the page loads, this outputs "wuz hur" properly. But when I try to call yourMom("wuz hur") from the chrome js console (as I do sometimes to test normal JS functions), I get a "ReferenceError: yourMom is not defined" Are functions generated by coffeescript available in this way? an easier way to share global methods/variables is to use @ which means this. @yourMom = (location) -> console.log location yourMom "wuz hur" Nicer syntax and easier to read, but I

Rails before_filter for specific actions in controller

僤鯓⒐⒋嵵緔 提交于 2019-11-30 04:19:45
def new before_filter do redirect_to "/" unless current_admin || current_company flash[:notice] = 'You dont have enough permissions to be here' unless current_admin || current_company end CODE CODE CODE end def edit before_filter do redirect_to "/" unless current_admin.id = 5 flash[:notice] = 'You dont have enough permissions to be here' unless current_admin || current_company end CODE CODE CODE end This is the code that I want to do, but I cant figure out how to do it right. What I want to achieve is to apply a before_filter rule for each of my actions. So perhaps a User can acces de INDEX

Passing ActionView::Helpers::FormBuilder to a partial

六眼飞鱼酱① 提交于 2019-11-30 03:56:51
问题 I am atempting to dinamically create form elements given a certain AJAX request. This is my setup: View: <%= link_to 'Next', check_unique_id_students_path, :remote => true %> <div id="guardian_student_details"></div> Controller: def check_unique_id @student = Student.new @this_form = ActionView::Helpers::FormBuilder.new(:student, @student, @template, {}, proc{}) end JS: jQuery("#guardian_student_details").html("<%=escape_javascript(render :partial => "student_details", :locals => { :s =>

Sass / SCSS Mixin for Clearfix - best approach?

◇◆丶佛笑我妖孽 提交于 2019-11-30 03:55:53
I want to remove the clearfix class from my HTML and include a clearfix mixin in my SCSS (Rails 3.1 application). What is the best approach to this? I am thinking of just taking the HTML 5 Boilerplate clearfix and turning it into a mixin, then @including it within the CSS for elements that need clearfixing. Copied from HTML5 Boilerplate: /* The Magnificent Clearfix: Updated to prevent margin-collapsing on child elements. http://j.mp/bestclearfix */ .clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; } .clearfix:after { clear: both; } /* Fix

Where to put Galleria (jQuery image gallery framework) in Rails 3.1 Asset Pipeline?

落花浮王杯 提交于 2019-11-30 03:46:28
I'm a bit confused as to where to put a jQuery framework like Galleria in Rails 3.1 's new Asset Pipeline ? I know it, technically, should go into /vendors/assets/javascripts but , it is my understanding that, the Galleria folder with the jQuery & themes wants to be in root ( /galleria ) of the live site in order to work correctly. Also, while we're at it, where to put the following script so it will appear only on the page(s) with a gallery? <script> $('#gallery').galleria({ width:500, height:500 }); </script> Edit : Surprised there's no response!?! Maybe Galleria isn't that popular? These

Heroku: No Rakefile found (but works locally)

穿精又带淫゛_ 提交于 2019-11-30 02:54:50
问题 I cloned one of my own apps using Rails 3.1.3, created an app on Heroku on stack cedar, pushed the to Heroku, and then tried to run heroku run rake db:migrate and got this error message No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) /usr/local/lib/ruby/1.9.1/rake.rb:2367:in `raw_load_rakefile' /usr/local/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile' /usr/local/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling' /usr/local/lib/ruby/1.9.1/rake

Carrierwave add a watermark to processed images

社会主义新天地 提交于 2019-11-30 02:45:25
Im trying to add a watermark to processed images with below code I got from several resources: def watermark manipulate! do |img| logo = Magick::Image.read("#{Rails.root}/assets/images/watermarks/watermark.png").first img = img.composite(logo, Magick::SouthEastGravity, Magick::OverCompositeOp) end end Only problem is, you guess it, does not work. I get no errors in log/console whatsoever This is my method inside my uploaded and called like: def function version :thumb do process :resize_to_fill => [96, 96] process :watermark end end Any thoughts on getting some logs on why this doesn't work? I