ruby-on-rails,activerecord,blogs,runtime-error,declarative-authorizationRelated issues-Collection of common programming errors


  • Duncan
    ruby-on-rails apache passenger compatibility ruby-1.9.3
    I am trying to set up my Rails app on Apache. I am using Passenger to load my Rails App. It seems like Passenger does not support the new Ruby hash format x: y but supports the old one 😡 => y. The Ruby version I am using is 1.9.3This is the error message I get:categories_controller.rb:12: syntax error, unexpected ‘:’, expecting ‘}’ format.json { render json: @categories } categories_controller.rb:23: syntax error, unexpected ‘:’, expecting ‘}’ format.json { render json: @category } categorie

  • Hayk Saakian
    ruby-on-rails heroku mongoid delayed-job
    I’m using delayed_job to create large numbers of jobs, nearly all at one time, to be done at a later time, if the number of jobs gets too high, after a certain amount of time, every job is cleared from the queue regardless of it’s state.the following rails project illustrates this issue: https://github.com/hayksaakian/taskbreakerto recreate the issue, create several tasks (say 5 to 15), each with around 100 goals (from the web interface, or console)then in console attempt to do these tasks with:

  • Bearish_Boring_dude
    ruby-on-rails ruby
    if (ax_response = OpenID::AX::FetchResponse.from_success_response openid_response)The above line if i remove the ( ) paranthesis it throws a syntax error ..Unexpected tIdentifier . Why ?

  • Oded Harth
    ruby-on-rails heroku
    I got this error:syntax error, unexpected kEND, expecting $endWhat’s the difference between kEND and $end ?

  • Deon Heunis
    ruby-on-rails ruby ruby-on-rails-3
    The following code results in an errorExample 1if params[:id] == ‘2’ || params.has_key? :idabort(‘params id = 2 or nothing’) endsyntax error, unexpected tSYMBEG, expecting keyword_then or ‘;’ or ‘\n’ if params[:id] == ‘2’ || params.has_key? :idHowever, switching the conditional statements || adding parentheses works 100%.Example 2if params.has_key? :id || params[:id] == ‘2’ abort(‘params id = 2 or nothing’) endExample 3if (params[:id] == ‘2’) || (params.has_key? :id)abort(‘params id = 2 or nothi

  • Ziu
    ruby-on-rails
    I am trying to complete the signup part,but every time i try to signup at the site the server would show the information that the database had rollback. And i do can’t find the new user in the db file.Started POST “/users” for 127.0.0.1 at 2014-03-12 17:09:50 +0800 Processing by UsersController#create as HTML Parameters: {“utf8″=>”?”, “authenticity_token”=>”CkaL2ZiNW8FWXRjPawShiNhQGmP+EHDMgSBbSyihE5E=”, “user”=>{“name”=>”foo1”, “email”=>”[email protected]”, “password”=>”[F

  • Taylor Mitchell
    ruby-on-rails ruby
    I am trying to make my users have a profile id when they create their account so I can create a profile page based on id. I do not want them to have a username. The problem is when I created a user it worked just fine, however when I edit the user information which is what I use on the profile page it gives me the error…syntax error, unexpected tSYMBEG, expecting keyword_do or ‘{‘ or ‘(‘ before_save :create_unique_profile_idThey sign up using email and passwords and when they go to edit they h

  • Edward Castaño
    ruby-on-rails ruby-on-rails-3 syntax-error
    I am new to programming and teaching myself RoR. I am using http://ruby.railstutorial.org as my first guide. I thought I was doing well, then a seemingly simple issue came up that even after several reads of good post on stack related to this topic I still can’t fix it. I would appreciate it if someone could kindly point out the issue/s I have within my code.Thank you.I am getting this error.C:/Sites/rails_projects/sample_app/app/controllers/users_controller.rb:23: syntax error, unexpected $end,

  • Jean-Rémy Revy
    ruby-on-rails unexpectendoffile
    i’m just started making blog via RoR, using blog-from-scratch guide and i’ve got some unexpected content on my index page. Here is the picture: http://i.minus.com/ibpnYRmlPv7IW3.png Some hash-like string under the title is that unexpected thing.index_page code:<h1>Recent posts</h1> <table><tr><th>Title</th><th>Text</th></tr><%= @posts.each do |post| %><tr><td style=”border: solid 2px;”><%= post.title %></td><t

  • krishnareddy
    ruby-on-rails json httpwebrequest
    I am sending below json data as a param from body of posterzip='{“zipcode”:”501234″,”cityname”:”hyd”,”countyname” : “Poweshiek”,”statename” : “Iowa”}’&Accept=application%2FjsonI am getting error’MultiJson::DecodeError`enter code here`743: unexpected token at ‘zip='{“zipcode”:”501234″,”cityname”:”hyd”,”countyname” : “Poweshiek”,”statename” : “Iowa”}’&Accept=application%2Fjson’Rails.root: e:/rails/vivadesi’ bel

  • kolosy
    mysql activerecord jruby
    this happens when i deploy my app to glassfish as a war:[#|2011-06-24T17:11:40.903-0500|INFO|glassfish3.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=135;_ThreadName=Thread-1;|PWC1412: WebModule[null] ServletContext.log():/!\ FAILSAFE /!\ Fri Jun 24 17:11:40 -0500 2011Status: 500 Internal Server Erroryield called out of block/home/glassfish/glassfish/domains/domain1/applications/trainer-web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.2/lib/arjdbc/jdbc/connection.r

  • Gal Ben-Haim
    mysql ruby-on-rails-3 activerecord
    I’m changing my Rails 3.2 app from Postgres to Mysql,I have a model with default_scope :order => ‘posts.created_at DESC’if i query for posts with IDs between with the following code:Post.find(:all, :conditions => [‘id >= ? AND id <= ?’, min_id.to_i, max_id.to_i]) if min_id && max_idI get wrong ordered results (because multiple rows have the same created_at time), for example: if post1 was created by code before post2 but they have the same created_at timestamp I would expect the

  • Lee
    ruby-on-rails activerecord inheritance super destroy
    I have a Commentable class that inherits from ActiveRecord::Base and an Event class that inherits from Commentables.I have overwritten the destroy methods in both of these classes, and Event.distroy calls super. However, some unexpected things happen. Specifically, the Event’s has_and_belongs_to_many associations are deleted. I think this is happening because some modules are getting included between the Commentables and the Event class, but not sure if there is a way to stop this.Here’s the sim

  • esilver
    ruby-on-rails json serialization activerecord
    Ruby on Rails adds the “as_json” method to many common classes, which turns ActiveRecord objects into hash objects that can then be sent to a JSON serializer. Recently I encountered a bug in my code related to this method and it’s treatment of boolean values.I can summarize the bug very concisely:{“foo” => true}.as_jsonI would expect this method to return an identical hash. Instead, it returns{“foo” => “true”}This appears to be by design, as per line 157 in encoding.rbAS_JSON = ActiveSuppo

  • Nox
    ruby-on-rails activerecord cancan
    I’m setting up a working application on a new environment, and after running ‘bundle install’ I try to launch an application. And I get a following error:ActionView::Template::Error (compile error D:/Dev_apps/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.1.0.rc5/lib/active_record/attribute_methods/read.rb:85: syntax error, unexpected kEND D:/Dev_apps/Ruby187/lib/ruby/gems/1.8/gems/activerecord-3.1.0.rc5/lib/active_record/attribute_methods/read.rb:87: syntax error, unexpected $end, expecting kEND

  • leonel
    ruby-on-rails ruby activerecord
    I have this query but it’s not giving me the expected results: User.all(:conditions => [“company_id == ? AND role_id == ? OR role_id == ? OR role_id == ?”, X, 1,2,3 ])It’s supposed to mean: Get all the users with X company_id AND their roles can be either 1 or 2 or 3.So it can be either of those roles, but ALL of those users have to be from THAT company_id.

  • Matt Mazur
    ruby-on-rails-3 activerecord
    My Rails 3 app has a UserAction object that I use to store information about actions taken on my site.I’m trying to filter the results so that I only get ones where the data attribute is set to a specific value, but for some reason it always returns an empty array.Here’s an example from the console showing the first record, a query that returns it based on the ‘action’ attribute, and the one that’s not working for the ‘data’ attribute:> UserAction.first UserAction Load (39.6ms) SELECT “user_

  • kdavie
    ruby-on-rails activerecord associations has-one
    I have a has_one association for a location on a company entity:class Location < ActiveRecord::Baseattr_accessible :city, :country, :postal_code, :state endclass Company < ActiveRecord::Basehas_one :headquarters, :class_name => “Location” endThe underlying schema for the company entity contains a location_id attribute. I expect I should be able to access a company’s headquarters location info like so:Company.find(12345).headquartersHowever, this results in an exception:SELECT “locations

  • ajw
    ruby-on-rails ruby activerecord rake
    When I run the rake task “test:functionals” for my RoR app, it produces this error: >rake test:functionalsrake aborted! C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:380: syntax error, unexpec ted keyword_end, expecting $endTasks: TOP => test:functionals => test:prepare => db:test:prepare => db:abort_if_pending_migrations => db:load_conf igI have checked my code for syntax errors. Why would transactions.rb have a syntax error?

  • fct
    activerecord ruby-on-rails-3.2 globalize3
    I have complex Model query with globalized fields, containing:1) scalar-fields: select(“field1, field3, joined1.field1, count(1), …”)2) inner joins: joins(:book =>[{:article => :writer}, … ])3) where: where(“writer.name like ?”, “%#{name}%”)4) group-by: group(“field1, field3, … “)5) order-by: order(“count(1) desc”)This query works but show me a lot of problems: n+1 queries, retrieve unrequested fields (globalize fields on join i18n), unaccepted clauses in select as count(1), always retriev

  • user2821643
    php mysql blogs
    Hello I am working on making a blog php script and I cant get it to work. I keep getting a error.If it is useful I am using Microsoft WebMatrix 3. <?php Print “<div class=””post””><h2 class=””title””><a href=””#””>” .$info[‘title’] .”</a></h2><p class=””meta””>Posted by <a href=””#””>” .$info[‘name’] .”</a>”.$info[‘date’] .”<div class=””entry””><p>”.$info[‘post’]”</p></div></div>”; ?>

  • Yannis Rizos
    blogs wordpress
    I work for a small company where I maintain a number of project all at once. I would like to create a blog and note software changes/update so that I can keep track of things. Plus it will also serve as help tool for other if they need help. I would like to install something locally on my machine or network, either ASP or PHP is fine. Which software would you recommend? Is it good idea, bad idea? Has anyone done it? I have worked with wordpress and I like it but I am afraid it is not best for co

  • Suresh Pattu
    javascript jquery json wordpress blogs
    I am trying to Display Latest Post Outside of WordPress with JSON and jQuery I followed the steps which are given in this blog post. But is not working for me. Here is the blog post linki tried Here it is not workingit shows Uncaught SyntaxError: *Unexpected token < blog.rangde.org/api/get_recent_posts/?count=1&page=0&callback=jQuery17206551494831219316_1338883023819&_=1338883023833:3*

  • Mr C
    javascript html css comments blogs
    Blog URL: http://theforeigntwo.blogspot.com.auURL of concern: http://theforeigntwo.blogspot.com.au/2012/07/steve-nash-post.html?showComment=1344125682577#c3764506429069823377In the comments, there is a second “Reply” button at the bottom, filling about 400px, and an “Add comment” button about the same size, which I would like to remove. The “Add comment” button seems redundant since there is already a comment form in place – it loads a larger comment form when clicked.I’m not sure on which co

  • Vieenay
    ruby-on-rails ruby blogs
    I am trying to get user who edits article in blog. I am able to get user who create article but got stuck while getting user who edits it. I tried with <%= @aritcle_update_user.username unless @article.user.nil? %> putting it in articles/show.html.erb(basically I am trying to show editing user on show page of articles). I have put this def update@article = Article.find(params[:id])if @article.update_attributes(params[:article])flash.notice = “Article ‘#{@article.title}’ Updated!”redirect_

  • Rajesh
    ruby-on-rails activerecord blogs runtime-error declarative-authorization
    I am trying to configure declarative authorization to my rails blog app. After doing all as required, I did rails s to start the server. I have got stuck with the following error.rails s /var/lib/gems/1.8/gems/activerecord-3.2.9/lib/active_record/dynamic_matchers.rb:50:in `method_missing’: undefined local variable or method `scopes’ for ActiveRecord::Base:Class (NameError)from /var/lib/gems/1.8/gems/declarative_authorization-0.5.2/lib/declarative_authorization/in_model.rb:37:in `included’from /v

  • Ahmad Alfy
    php joomla blogs addthis custom-url
    I’ve overwritten the “blog.php”, for Category Blog to put the AddThis social media sharing plugin at the bottom of each article. Working on joomla 3.0The Category blog layout displays many articles per page. By default AddThis uses your current page to share/like/tweet/etc.My add this code looks like this:<div class=”article-sharing”><!– AddThis Button BEGIN –><div class=”addthis_toolbox addthis_default_style”><a class=”addthis_button_facebook_like” fb:like:layout=”button_

  • tinku
    facebook login localhost blogs
    Error obtained is An error occurred, please try again laterI created new facebook app and go the APP ID. I entered domain name as blogspot.in and redirect URL as my blogI then used the below code from<div id=”fb-root”></div><script>window.fbAsyncInit = function() {FB.init({appId : ‘YOUR_APP_ID’,status : true, cookie : true,xfbml : true,oauth : true,});};(function(d){var js, id = ‘facebook-jssdk’; if (d.getElementById(id)) {return;}js = d.createElement(‘sc

  • Moayad Mardini

  • webmaster alex l
    javascript blogs word-count
    I have a div with an ID “shortblogpost”. I would like to count up to 27th word then stop and add “…” at the end.I was trying the following code. Problem, Its counting letters and not words. I think its using jQuery and not strait up JavaScript?I need to use JavaScript for various server reasons only<script type=”text/javascript”> var limit = 100,text = $(‘div.shortblogpost’).text().split(/\s+/),word,letter_count = 0,trunc = ”,i = 0;while (i < text.len

  • user12920
    php runtime-error
    Parse error: syntax error, unexpected ‘Pre’ (T_STRING), expecting ‘,’ or ‘;’ in your code on line 719719: if (get_the_author_meta(‘Pre-Rolls’) != ‘0’) { echo get_the_author_meta(‘Pre-Rolls’); }I dont see where I’m missing a , or ;?Does it not like the “-” in Pre-Rolls? Is that the problem?

  • Pupil
    matlab optimization constraints limit runtime-error
    I am using lower limit and upper limit in the fminbnd function according to the legit domain values of my coefficients as following:[x,fval,exitflag] = fminbnd(@(x) minimize_me(sill, x(1), x(2), x(3), cov), [x1l x2l x3l], [x1u x2u x3u], opts);Where the [x1l x2l x3l] and [x1u x2u x3u] are the vectors representing the lower limit and upper limit for the optimized coefficients. The domain of my problem is given as following:0<=x1l<=5 0<=x1u<=50<=x2l<=5 0<=x2u<=50<=x3l<

  • Ved
    javascript dom runtime-error appendchild
    I am getting runtime JS error like : “Unexpected call to method or property”. Here is the code :var comboInput = document.getElementById(“Combo”);var option1 = document.createElement(“option”);option1.value = “-1”;option1.innerHTML = “–Select–“;comboInput.appendChild(option1); //At this line debugger breaks and// throws the above errorI gone through some of similar questions on SO about this issue but still not getting the solution.Please help.. Thanks in adv…

  • Maddy
    java list arraylist runtime-error
    I have the following code in java, which takes in input from the user. It is basically a simple database system.ArrayList<String> commands = new ArrayList<String>(); ArrayList<ArrayList<String>> blocks = new ArrayList<ArrayList<String>>(); ArrayList<String> list = new ArrayList<String>();System.out.println(“Enter the transaction commands.\n”);Scanner scan = new Scanner(System.in);while(!(line = scan.nextLine()).toLowerCase().equals(“end”)) {command

  • The Starfox
    android android-activity android-service runtime-error
    Im getting an “java.lang.IllegalAccessError class ref in preverified class resolved to unexpected implementation” error when I push a button that starts a method in MainActivity which is supposed to start a new Activity. What can I do to fix this? This is my first attempt to make an android application, so ill need step by step instructions :)Also I havent been able to test if it works yet, but if you notice anything wrong with my AugiActivity service implementation or the local broadcast impl

  • PeeHaa
    php runtime-error
    am new to oops in php. this is my first oops program. this program is so basic(form program) but i can’t figure out what is tat i have to do. Sorry if this is a newbe question, but I am new at this. am getting the error as Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /ni.class.php on line 34 line34 :$str=$ab->startform(‘#’,’post’,’myform’).”.<?phpclass ni{function startForm($action=’#’,$method=’post’,$id=NULL){$str=”<form><action =\”$action\” method=\”$

  • The Phoenix
    windows-7 laptop troubleshooting asus runtime-error
    Here is one for you to sink your “teeth” into! All my Window 7 Troubleshooters will not run. They all come up with error code 0x80070003 which Fix It indicates is a runtime error as I have it. I have an Asus K53E-BBR21 laptop with an I5 CPU @2450. It is basically standard hardware and software equipment with an added 4 Gig of Ram for a total of 8 Gig Ram.I have cold rebooted and still no improvement. I have noted that other programs like Asus Vibe 2 will not boot or boot and shut down at start

  • ramcha
    c data-structures runtime-error tournament
    I am trying to implement a simple tournament in C.#include <stdio.h>int main(void) {int tourn[100], n, i;printf(“Give n:”);scanf(“%d”, &n);printf(“\n n = %d \n”, n);for(i = n; i <= (2*n)-1; i++)scanf(“%d”, &tourn[i]);build(tourn, n);printf(“\n Max = %d \n”,tourn[1]);printf(“\n Next Max = %d \n”,nextmax(tourn, n));}void build(int tourn[], int n) {int i;for(i = 2*n-2; i > 1; i = i-2)tourn[i/2] = max(tourn[i], tourn[i+1]);} int nextmax(int tourn[],int n) {int i = 2;int next;nex

  • l19
    perl sed runtime-error
    I’ve got file.txt which looks like this:C00010018;1;17/10/2013;17:00;18;920;113;NONE C00010019;1;18/10/2013;17:00;18;920;0;NONE C00010020;1;19/10/2013;19:00;18;920;0;NONEAnd I’m trying to do two things:Select the lines that have $id_play as 2nd field. Replace ; with – on those lines.My attempt:#!/usr/bin/perl$id_play=3; $input=”./file.txt”; $result = `sed s@^\([^;]*\);$id_play;\([^;]*\);\([^;]*\);\([^;]*\);\([^;]*\);\([^;]*\)\$@\1-$id_play-\2-\3-\4-\5-\6@g $input`;And I’m getting this error:sh:

  • 00101010 10101010
    c# visual-studio-2010 visual-studio error-handling runtime-error
    I have a ErrorRecorder App, which prints the error report out and asks if the user wants to send that report to me. Then, I have the main app. If an error occurs, It writes the error report to a file and asks ErrorRecorder to open that file to show user the error report.So I am catching most of my errors using Try/Catch. However, what if an error occurs that was completely unexpected and it shuts down my program.Is there like an Global/Override method or something of that kind, that tells the pr

  • Rajesh
    ruby-on-rails activerecord blogs runtime-error declarative-authorization
    I am trying to configure declarative authorization to my rails blog app. After doing all as required, I did rails s to start the server. I have got stuck with the following error.rails s /var/lib/gems/1.8/gems/activerecord-3.2.9/lib/active_record/dynamic_matchers.rb:50:in `method_missing’: undefined local variable or method `scopes’ for ActiveRecord::Base:Class (NameError)from /var/lib/gems/1.8/gems/declarative_authorization-0.5.2/lib/declarative_authorization/in_model.rb:37:in `included’from /v

  • Andrés
    ruby-on-rails-3.2 declarative-authorization
    I’m tracking the activities with a model:class Activity < ActiveRecord::Basebelongs_to :model, polymorphic: true… endAn the idea is the user can read one activity only if he can read the model (polymorphic). This is what I made:has_permission_on :activities, to: :read doif_permitted_to :read, :model, context: :milestones # or…if_permitted_to :read, :model, context: :tasks endBut when I tried in console:Activity.with_permissions_to(:read)I get:NoMethodError: undefined method `length’ for

  • lulalala
    ruby-on-rails-3 declarative-authorization rails-cells
    using the gems cells and declarative_authorization (along with Devise) and I’m trying to figure out how to include the permitted_to? into the cell templates. So far I’ve added this to my cells Cell (the Devise one works for it’s helpers):class SidebarCell < Cell::Railsinclude Devise::Controllers::Helpershelper_method :current_userinclude Authorization::AuthorizationHelperhelper_method :permitted_to?def display(args)@object = args[:object]@notice = args[:notice]@alert = args[:alert]renderenden

  • Steven Ou
    ruby-on-rails bundler declarative-authorization
    I’m running bundler with rails 2.3.4.I’m trying to get declarative_authorization to work (I added it to my Gemfile). The error I’m getting is undefined local variable or method ‘filter_resource_access’.I’m guessing this means that declarative_authorization isn’t loading? Since I’m using bundler I don’t have a config.gem line for it in environment.rb. If I add it in, though, it throws an error trying to start the server: Uninitialized constant Authorization.Not too sure what to do… Help would b

  • Jamal Abdul Nasir
    ruby-on-rails declarative-authorization
    i am using declarative_authorization… when i try to access current_user, it gives me the error undefined local variable or method `current_user’… can anyone help me out..?thnx…

  • Antarr Byrd
    ruby-on-rails declarative-authorization
    I keep getting that error when trying to access any of my views. I’m trying to setup Declaritive Authorization.class User < ActiveRecord::Baseacts_as_authentic do |c|c.login_field = :usernameendROLES = %w[admin moderator subscriber]has_and_belongs_to_many :channelshas_many :channel_modsnamed_scope :with_role, lambda { |role| {:conditions => “roles_mask & #{2**ROLES.index(role.to_s)} > 0 “} }def role_symbolsrole.map do |role|role.name.underscore.to_symendenddef roles=(roles) self.r

  • Lance Roberts
    ruby-on-rails ruby roles declarative-authorization
    I’m getting the following error in my deployed Rails 2.3.5 application:NoMethodError (undefined method `to_sym’ for nil:NilClass):My local testing install of the application, which uses Sqlite, doesn’t get the error, but my deployed app running Mysql does. The only other difference between the two is I’m running Ruby 1.8.7 on my local machine and 1.8.6 on my deployment server.I’ve included the code from User.rb and the error log below. I set this up following the Declarative Authorization and

  • Antarr Byrd
    ruby-on-rails authlogic declarative-authorization
    I get this error when trying to register a new user.NoMethodError (undefined method save’ for nil:NilClass):app/controllers/users_controller.rb:49:increate’app/controllers/users_controller.rb:48:in `create’class UsersController < ApplicationControllerbefore_filter :require_no_user, :only => [:new, :create]before_filter :require_user, :only => [:show, :edit, :update]#filter_resource_accessdef index@users = User.allrespond_to do |format|format.html # index.html.erbformat.xml { render :xm

Web site is in building

I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money