ruby-on-rails,ruby-on-rails-3,simple-form,jquery-select2,select2-railsRelated issues-Collection of common programming errors
 
 Huy
 ruby-on-rails ruby ruby-on-rails-3 rspec
 I have a unit test where I was stubbing place.ext_fb_place_id usinglet(:place) { stub(:place, ext_fb_place_id: SecureRandom.random_number(20_000_000), facebook_metadata: {category: nil}, lat: 33.129147303422, lng: -96.653188420995, name: “In & Out Burger”) }I had to change my code to use the string key instead of the dot operator. That is, I had to use place[“ext_fb_place_id’] to get the correct value. However, this throws the following error:Stub :place received unexpected message :[] with
 Charles
 ruby-on-rails ruby-on-rails-4
 I have an attribute which name is alias and method which create_alias.I use create_alias method as before_validation callback.In the method decleration I have following lines while ProjectType.find_by_alias(tmp) != nil tmp = self.alias + “-” + i.to_si += 1 endAs you can see, the code tries to create unique alias but on rails 4.0 we encounter this error message.SyntaxError: /home/vagrant/.rvm/gems/ruby-1.9.3-p194@comRails4/bundler/gems/rails-39555a5b1989/activerecord/lib/active_record/dynamic_ma
 John Smith
 ruby-on-rails ruby-on-rails-3
 In my adminpage#index controller i have defined @software:if Software.first != nil@software = Software.firstelse@software = Software.new end Then in my form i have:<% form_for(@software), :url => adminpage_setting_path do |f| %><%= f.label ‘Name der zugelassenen Software’ %><%= f.text_field :software %><br><%= f.label ‘Software-Relase’ %><%= f.text_field :release %><br><%= f.label ‘Softwareverantwortlicher’ %><%= f.text_field :sv %><br&
 Jngai1297
 ruby-on-rails
 Why am I getting this error ? /Users/judyngai/.rvm/gems/ruby-2.0.0-p195/gems/ajaxful_rating-2.2.9.1/lib/axr/model.rb:23: syntax error, unexpected ‘,’, expecting =>I made a new app in rails 4 and ruby 2.0 – the latest versions I installed the ajaxful-rating gem into my rails app and ran bundle install (version 2.2.9.1) I changed my database yml file to use pg then do rake db:create and this error popped up. Is the gem not compatible with rails 4? I consider this issue before hand maybe I shoul
 mu is too short
 ruby-on-rails ruby-on-rails-3 coffeescript erb actionview
 I am using Rails 3.1, it seems that I could not use Ruby script after a CoffeeScript statement in my create_error.js.coffee view file for the AJAX response.If I do it like this it will work:<% if @attached_image.errors.any? %>alert ‘something is wrong’ <% end %>but if it is like the following, with a <% %> after the CoffeeScript statement,errors_block = ‘<div id=”errors_block”></div>’ <% if @attached_image.errors.any? %>something.. <% end %>I will alway
 Alfred Rowe
 ruby-on-rails ruby json sinatra
 I have a sinatra app mounted inside a rails 3.2.12 app which accepts JSON posts. The problem is that I get an error when one of the strings contains an asterisk(*) or a harsh(#) symbol. These are required because a USSD service will push data to my end point wich will contain “*712#”. I am positive its got to do with the * and # since removing them seams to work without throwing MultiJson::LoadError at /ussdpush/requests ==========================================> 399: unexpected token at ‘{“
 Trace
 ruby-on-rails ruby ruby-on-rails-3
 Actually this currently doesnt work at all@category = Category.find(params[:id])@sub_categories = @category.sub_categoriesif @sub_categories@designs = []@sub_categories.each do |sub_cat|@designs << sub_cat.designs.paginate :page => params[:page], :order => ‘name’, :per_page => @per_pageend endIts failing on this syntax errorcategories_controller.rb:21: syntax error, unexpected tSYMBEG, expecting kEND …<< sub_cat.designs.paginate :page => params[:page], :order …Basical
 Pan Thomakos
 ruby-on-rails haml partials
 I have a partial that represents a header that I want to place on some of my pages. Each page, though, has a different title. I want to ‘inject’ this title into the partial.Here’s what I’m trying to do, although it’s not working:= render :partial => “section_head_top”%span( id= “section_head_header”) Apply= render :partial => “section_head_divider”Section_head_top partial code:#section_head#section_head_top#section_head_contentI want the %span line to be inside of the section_head_content div. I
 weed
 ruby-on-rails ruby coffeescript asset-pipeline
 I want to deploy my Rails app to heroku but assets compile fails. In local environment, it works well.Your bundle is complete! It was installed into ./vendor/bundleCleaning up the bundler cache. —–> Writing config/database.yml to read from DATABASE_URL —–> Preparing app for Rails asset pipelineRunning: rake assets:precompilerake aborted!Error: Parse error on line 13: Unexpected ‘INDENT'(in /tmp/build_iztv4ybnwpqh/app/assets/javascripts/require_dir/view_after _key_recieve.js.coffee)Lo
 jdl
 ruby-on-rails syntax passenger
 Running: Apache 2.2.3 Ruby 1.8.7 Rails 2.3.4 Passenger 2.2.5Error message: /var/www/derscheidfamily/app/controllers/greetings_controller.rb:14: syntax error, unexpected ‘/’, expecting ‘\n’ or ‘;’ def app/controllers ^ /var/www/derscheidfamily/app/controllers/greetings_controller.rb:20: syntax error, unexpected ‘/’, expecting ‘\n’ or ‘;’ def app/helpers ^ Exception class: SyntaxError Application root: /var/www/derscheidfamilygreetings_controller is as follows:class GreetingsController < App
 
 Huy
 ruby-on-rails ruby ruby-on-rails-3 rspec
 I have a unit test where I was stubbing place.ext_fb_place_id usinglet(:place) { stub(:place, ext_fb_place_id: SecureRandom.random_number(20_000_000), facebook_metadata: {category: nil}, lat: 33.129147303422, lng: -96.653188420995, name: “In & Out Burger”) }I had to change my code to use the string key instead of the dot operator. That is, I had to use place[“ext_fb_place_id’] to get the correct value. However, this throws the following error:Stub :place received unexpected message :[] with
 John Smith
 ruby-on-rails ruby-on-rails-3
 In my adminpage#index controller i have defined @software:if Software.first != nil@software = Software.firstelse@software = Software.new end Then in my form i have:<% form_for(@software), :url => adminpage_setting_path do |f| %><%= f.label ‘Name der zugelassenen Software’ %><%= f.text_field :software %><br><%= f.label ‘Software-Relase’ %><%= f.text_field :release %><br><%= f.label ‘Softwareverantwortlicher’ %><%= f.text_field :sv %><br&
 mu is too short
 ruby-on-rails ruby-on-rails-3 coffeescript erb actionview
 I am using Rails 3.1, it seems that I could not use Ruby script after a CoffeeScript statement in my create_error.js.coffee view file for the AJAX response.If I do it like this it will work:<% if @attached_image.errors.any? %>alert ‘something is wrong’ <% end %>but if it is like the following, with a <% %> after the CoffeeScript statement,errors_block = ‘<div id=”errors_block”></div>’ <% if @attached_image.errors.any? %>something.. <% end %>I will alway
 jwarzech
 ruby ruby-on-rails-3 activerecord
 This looks like it should be something pretty easy but I can’t seem to get it to work. I have a model with a has_many relationship and I’d like a scope on the parent that allows me to select only certain attributes for each.An example:class Bakery < ActiveRecord::Basehas_many :pastriesscope :summary, select([:id, :name, ‘some option calling pastries.summary’])class Pastry < ActiveRecord::Basebelongs_to :bakeryscope :summary, select([:id, :image_url])I’d like to be able to call something l
 Trace
 ruby-on-rails ruby ruby-on-rails-3
 Actually this currently doesnt work at all@category = Category.find(params[:id])@sub_categories = @category.sub_categoriesif @sub_categories@designs = []@sub_categories.each do |sub_cat|@designs << sub_cat.designs.paginate :page => params[:page], :order => ‘name’, :per_page => @per_pageend endIts failing on this syntax errorcategories_controller.rb:21: syntax error, unexpected tSYMBEG, expecting kEND …<< sub_cat.designs.paginate :page => params[:page], :order …Basical
 Pawel Goscicki
 ruby-on-rails-3 rubygems rvm bundler
 Bundler v1.2.3 RubyGems v1.8.24 RVM (latest) Rails v3.2.9I’m using binstubs for my Rails application with those defaults (~/bundle/config):— BUNDLE_PATH: .bundle BUNDLE_BIN: .bundle/binThen I add .bundle/bin to $PATH (via a zsh script on chwd, so it’s not such a huge security hole) so I have correct gem binaries available.And this is mostly ok, apart from two issues.Issue 1When I cd into the app and type gem list I get a list of globally installed gems (not app’s gems). For app gems I need to
 John
 ruby-on-rails-3 haml gmaps4rails
 I have this piece of code to show multiple maps on a page:.row.span12- counter = 1- @users.each do |user|- map_visits = user.visits.to_gmaps4rails- unless map_visits.blank?.span3%div{ id: “container_#{counter}” }%div{ id: “map_#{counter}” }= gmaps(map_options: { zoom: 6, container_id: “container_#{counter}”, id: “map_#{counter}” }, markers: { data: map_visits } )- counter += counterIt returns an error “syntax error, unexpected keyword_ensure, expecting $end”, but I can’t really figure out what’s
 Ultimation
 ruby-on-rails ruby-on-rails-3
 I recently updated a rails app from 3.0.4 to 3.2.4 and I have a strange problem. It seems every array in my app has become frozen. For example if an array gets a set of articles from the database, that array will be instantiated at the first call of the method and will not change. If an article in the array is deleted in the database, it will still refer to it in the array. It only changes if I restart the server. However, when I call array.frozen? it returns false. And when I deploy to heroku I
 Ben
 html ruby-on-rails ruby-on-rails-3 forms
 I have a Rails form with a parent model and nested attributes for potentially multiple children of another model.The child model has an attribute which is manipulated in logic as an array, but is serialized to a YAML string using the Rails built-in serialize method.Within the form, I display each individual member of the array so that the user can selectively delete members.The problem happens when the user destroys all members. The form will not pass any value for the param to the Rails control
 Bill the Lizard
 ruby-on-rails-3 syntax cucumber debian
 I have some interesting issue with cucumber on rails. A colleague of mine can use Umlaute, such as ä ö ü from the german language. I can not. I just getsyntax error, unexpected $end, expecting keyword_end pointing at “Gültig bis”. We both use the same setup: rails 3.0.4, cucumber (0.10.3), cucumber-rails (0.5.1) and their common dependencies.Is it possible, because I am running cucumber tests on a VM (project included as shared folder, gems bundled inside. Confusing for me but working) with Debi
 Andrey Botalov
 ruby-on-rails twitter-bootstrap simple-form popover slim-lang
 I’m trying to show some popovers in a form I am currently building. They should appear when the user has focus on a specific field, but I can’t quite manage to do so, here is what I got (in Slim):#sample_form=simple_form_for sample do |form|=form.input :sample_name, placeholder: “Name”, rel=”popover” data-content=”content” data-original-title=”title”javascript:$(‘#sample_form input’).hover(function(){$(this).popover(‘show’)});And here is what I get when I try to load the page:…_form.html.slim:
 HarrisRobin
 ruby-on-rails simple-form
 Getting this error with simple_form:Here is my view page code :Contact Contact <%= simple_form_for(@contact) do |f| %> <%= form.error_notification %> <%= form.input :name, autofocus: true %> <%= form.input :email %> <%= form.input :content, as: :text %> <%=form.button :submit, ‘Submit’, class: ‘submit’ %> <% end %>Routes :HarrisRobin::Application.routes.draw do resources :contacts, only:[:new, :create] root to: ‘pages#about’ get ‘/projects’ =>’p
 user209835
 ruby-on-rails-3 collections simple-form
 Environment: Rails 3.2.1 SimpleForm 2.0.1 I have encountered users here and elsewhere asking similar questions via Google, but I have not yet found answers!I want to provide a series of checkboxes to define a contact’s preferences. I made a small test app using something I noticed on the simple_form demo app.My Contact model has a string attribute named “post_pref”In ContactsHelper I included this:def contact_preference_options[‘High Resolution’,’Web Resolution’,’Browser’,’Hard Copy Proof’] endI
 hyperrjas
 ruby-on-rails ruby ruby-on-rails-3 fancybox simple-form
 I have inside a fancybox box this form:<%= simple_form_for(@message, :remote => true, :html => {:multipart => true}, :url => { :controller => “users/messages”, :action => “create”} ) do |f| %><%= f.error_notification %><%= f.input :subject, :input_html => { :maxlength => 500} %><%= f.input :message_image, :as => :file %><%= f.button :submit, t(‘.send_message’), :class => ‘btn-large btn-primary’, “data-disable-with” => t(‘.send_message’)
 JJD
 ruby-on-rails ruby-on-rails-3 simple-form jquery-select2 select2-rails
 This select2 jquery library looks awesome. There is a Rails gem but it is very light on the documentation. I would like to generate a simple multiple drop-down menu, using autocomplete. How do I do that?This is my simple_form_for call:<%= f.input_field :neighborhood_names, url: autocomplete_neighborhood_name_searches_path, as: :autocomplete, data: { delimiter: ‘,’, placeholder: “Where do you want to live?”}, multiple: true, id: “selectWhereToLive”, class: “span8” %>I have successfully inst
 aperture
 jquery ruby-on-rails nested-forms simple-form
 I’m getting “Uncaught Error: Syntax error, unrecognized expression: #[object Object]_fields_blueprint” when clicking the link_to_add link in my nested form.form.html.erb<%= simple_nested_form_for(@post, :html => {:multipart => true}) do |f| %><%= f.error_notification %><div class=”form-inputs”><%= f.input :title %><%= f.input :content %><%= f.simple_fields_for :news_photos do |p| %><%= p.input :image %><%= p.input :caption %><% end %>&l
 lflores
 ruby-on-rails ruby-on-rails-3 simple-form polymorphic-associations
 I have three models: majors, careers, schools. You can add a review for each of them. The associations look like this: Major.rb, School.rb, Career.rbhas_many :reviews, as :reviewableReview.rbbelongs_to :user belongs_to :reviewable, polymorphic: trueUser.rb has_many :reviewsMy routes look like this: resources :majors, :schools, :careers do resources :reviews endI want to be able to show all reviews related to a specific major when you go to a url like this: majorfinder.com/majors/major-name/revi
 Nicholas John Martin
 ruby-on-rails-3 twitter-bootstrap simple-form
 I’m still learning RoR and have followed various tutorials online. In that process I believe I have messed up the nice flash notifications that Bootstrap 2 showed when validating Simple_Form submissions. I have tried to update my code, but without success. Here is what I have so far…Running: Rails 3.2.13 Ruby 2.0.0I just upgraded to Bootstrap 3 using this gem in my gemfile:gem ‘bootstrap-sass-rails’In my application.html.erb I have:<%= render ‘layouts/messages’ %>In my _messages partial
 Ryan Arneson
 ruby-on-rails-3 activerecord carrierwave polymorphic-associations simple-form
 I’m trying to set up a polymorphic association for photo uploads which are processed using Carrierwave. I’m using Simple Form to build my forms. I feel like the association is correct so I’m wondering if my problem is just something with the form or controller.Here are my associations:property.rb:class Property < ActiveRecord::Baseattr_accessible :image…has_many :image, :as => :attachable… endunit.rbclass Unit < ActiveRecord::Baseattr_accessible :image…has_many :image, :as => :
 user2876445
 ruby-on-rails ruby ruby-on-rails-4 simple-form
 I’m trying to create a simple app with the following models: categories –[has_many]–> questions –[has_many]–> answersI have the following code for creating categories + questions(categories/_form.haml.html):= simple_form_for(@category) do |f|= f.error_notification= f.input :title, label: “Category title: “= f.simple_fields_for :questions, @category.questions.build do |q|= q.input :content, label: “Question content: “= f.button :submitAnd I’m using all the same code for creating questions + a
 Gupta Anirudha
 css twitter-bootstrap jquery-select2
 I recently started to use bootstrap RC2 and jquery select2, but if I use it with bootstrap form-control class I get unexpected margins and looks weird.Could someone please give me a hint on this?html<div class=”form-group”><div class=”col-lg-6 sepereate-group”><select name=”gender” id=”gender” data-placeholder=”Select gender” class=”form-control select2″><option></option><option value=”1″>Male</option><option value=”2″>Female</option></se
 amit_pandey
 jquery-chosen jquery-select2
 Using any of these jQuery plugins, I am showing tag selection in a list box. Now when I am using Optgroup, it is possible that a particular value is common – say “Yes” in the following Manner -RelationshipYesNo Senior CitizenYesNoThe list should display as it is, but when selected instead of showing “Yes”, in the select box, it should show the followingRelationship : Yes Senior Citizen : NoHow can I change the tags display at runtime?
 JJD
 ruby-on-rails ruby-on-rails-3 simple-form jquery-select2 select2-rails
 This select2 jquery library looks awesome. There is a Rails gem but it is very light on the documentation. I would like to generate a simple multiple drop-down menu, using autocomplete. How do I do that?This is my simple_form_for call:<%= f.input_field :neighborhood_names, url: autocomplete_neighborhood_name_searches_path, as: :autocomplete, data: { delimiter: ‘,’, placeholder: “Where do you want to live?”}, multiple: true, id: “selectWhereToLive”, class: “span8” %>I have successfully inst
 Shruthi Ramesh
 jquery ruby-on-rails twitter-bootstrap jquery-select2
 In rails 4.0, I am using select2(bootstrap) plugin. I want to generate dynamic data in auto-completion list but data is not loading in the list. If i used below code, i will get an error like “Uncaught TypeError: Cannot call method ‘toUpperCase’ of undefined”. $(‘#DIV_NAME’).select2({placeholder: “Search for a names”,multiple: true,minimumInputLength: 1,ajax: { url: “autocomplete/names”,dataType: ‘json’,data: function (term) {return { q: term };},results: function (data) {return {results: data};
 j0k
 jquery jquery-select2
 I’m trying to programmatically clear a drop down using the fantastic Select2 library. The drop down is dynamically filled with a remote ajax call using the Select2 query option.HTML:<input id=”remote” type=”hidden” data-placeholder=”Choose Something” />Javascript:var $remote = $(‘#remote’);$remote.select2({allowClear: true,minimumInputLength: 2,query: function(options){$.ajax({dataType: ‘json’,url: myURL + options.term,error: function(jqXHR, textStatus, errorThrown){smoke.alert(textStatus
 oliboon
 javascript jquery jquery-select2
 I’m trying to use the Select2 library to display a list of categories. I have a working regular <select> at the moment.I added jquery, the stylesheet, the .js file and the function in my html.<link href=”/select2/select2.css” rel=”stylesheet”/> <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js” ></script> <script src=”/select2/select2.js”></script> <script>$(document).ready(function() { $(“#listCategorie”).select2(); }); </scrip
 Jorge Sampayo
 jquery jquery-select2
 I’m trying to read a collection from the html5 data-attribute of the input that is converted to select2 to create tags.This is working when I have one input:$(“.tags”).select2(width: ‘220px’tags: $(“.tags”).data(‘collection’) )But I will like to do it more safe using the data of the element itself, I tried this:$(“.tags”).select2(width: ‘220px’tags: $(this).data(‘collection’) )But it fails with the error:Uncaught query function not defined for Select2 investigador_aplicacionesDo you know if it i
 Anto
 html5 backbone.js backbone.marionette jquery-select2 bootstrapping
 I load values for select2 like the following way.Declare the Type var AdjustmentType = Backbone.Model.extend({url : Hexgen.getContextPath(“/referencedata/adjustmenttype”)});create instance for the Typevar adjustmentTypes = new AdjustmentType();load the values to select2 boxadjustmentTypes.fetch({success : function() {for(var count in adjustmentTypes.attributes) {$(“#adjustment-type”).append(“<option>” + adjustmentTypes.attributes[count] + “</option>”);}}}); $(“#adjustment-type”).s
 JanR
 javascript arrays jquery-select2 backgrid
 I am trying to integrate select2 in backgrid.js. Backgridjs has extension support for select2 and the code for that is {name: “gender”,cell: Backgrid.SelectCell.extend({optionValues: [[“Male”, “m”], [“Female”, “f”]]}),label: “Gender (SelectCell)”}so based on this i tried something like the below since i have to load values to select2 box from the servervar FetchSecurities = Backbone.Model.extend({url : Hexgen.getContextPath(“/referencedata/securities”) }); var fetchSecurities = new FetchSecuriti
 
 DubstepCat
 jquery asp.net-mvc jquery-ajax jquery-select2
 I need help writing the jquery/ajax to fill a Select2 dropdown box.For those who don’t know what Select2 is, it is a javascript extension to provide Twitter Bootstrap looks and search / type-ahead functionality to an html select list dropdown box. For more information look at the examples here: Select2 Github page UPDATED – Solved!So I finally put this all together, and the solution to my problems was that I was missing functions to format the results and the list selection. The code below produ
 JJD
 ruby-on-rails ruby-on-rails-3 simple-form jquery-select2 select2-rails
 This select2 jquery library looks awesome. There is a Rails gem but it is very light on the documentation. I would like to generate a simple multiple drop-down menu, using autocomplete. How do I do that?This is my simple_form_for call:<%= f.input_field :neighborhood_names, url: autocomplete_neighborhood_name_searches_path, as: :autocomplete, data: { delimiter: ‘,’, placeholder: “Where do you want to live?”}, multiple: true, id: “selectWhereToLive”, class: “span8” %>I have successfully inst
 Caner Çakmak
 jquery-select2 select2-rails
 I’m using Select2 with Rails and Mongoid and I have Sunspot Solr on the server side to do the searching. What I’m trying is to filter the data from mongo by solr, get that data by ajax request and group the results according to parent-child hierarchy. What I can’t figure out is when I search for a child and if there are multiple child results, the parent category is occuring multiple times. Please read below for more info:Here is my data in Mongo DB{ “_id” : ObjectId(“5209eb465a721ae827c661de”),
Web site is in building