Rails--Build a filter on top of geocoder search Posted: 06 Jan 2017 08:20 AM PST I'm currently using geocoder to filter images, On top of that, I want to add a category filter(not the dropdown select type, but each category gets displayed like a button and when I click it, its category_id get selected). So imagine a side bar that lists out all my categories and a location search input box. This is what I have so far. #index.html.erb <%= form_tag images_path, :method => :get do %> <p> Location<br> <%= text_field_tag :search, params[:search] %> <% submit_tag "Search", :name => nil %> </p> <% end %> <% @images.each do |image| %> <%= image_tag image.picture.url %> <% end %> #I have the location filter form and below that, it lists out the appropriate images. # imagescontroller def index #@categories = Category.all if params[:search].present? @users = User.near(params[:search], 50, :select => "users.*, images.*").joins(:images) @images = Image.joins(:categories).where(categories: { id: 3 }).joins(:users).merge(@users).distinct else @images = Image.joins(:categories).where(categories: { id: 3 }) end end As you can see the code above, I hardcoded the category to the third category, but the code does run successfully when i input a location. Background story: - Each image can have many users, each user can have many images.
- Each user has an address, and I use geocoder to find images that has users who are near a certain location.
- Each image has many categories and each category has many images.
- There're only five categories
Now the question is: how can I make the category form so that users can choose the category, rather than me hardcoding it. I want the page to load without refreshing the page. And I have very little knowledge on Jqury and Ajax, but I'm willing to look more into it, I do need some direction tho. Any solutions, suggestions or guidance are appreciated :) |
Create ipsets for iptables using Chef and data bags Posted: 06 Jan 2017 08:20 AM PST I'm a little bit stuck with implementing ipsets for iptables with Chef using data bags. I know you may say that this solution is not elegant and ideal, but believe me I have my own reasons why. What I'm trying to achieve; I need to create the ip set "allowed_subnet" for future using with iptables for whitelisting some ip addresses. The "allowed" ip addresses are in the data bag. Unfortunately I could not find that Chef supports ipset resource so I have to use execute. Please correct me if I'm wrong. Right, I have data bag with the IP list: { "id": "ipset_for_iptables", "ip_list": [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ] } Data bag name is equal to the "id". And I have my default recipe file default.rb where I've added the following code: package 'ipset' execute 'create timeout ipset' do command 'ipset create allow_selected hash:ip timeout 120' not_if 'ipset -L allow_selected' end execute 'create ipset' do command 'ipset create allowed_subnet hash:ip hashsize 8192' not_if 'ipset -L allowed_subnet' end servers = data_bag('ipset_for_iptables' , 'ipset_for_iptables') template "/opt/data/data_hosts.txt" do source 'ipset.erb' owner 'ipset' group 'ipset' action :create variables :properties => servers['ip_list'] end And now, my question is: How to add the IP addresses from the data bag to the ip set "allowed_subnet" using "execute" and "ipset" linux command. Here is the template "ipset.erb" content: <% @properties.each do |host|%> <%= host['ipaddress'] %> <% end %> BTW, I'm not sure that this template is correct, this is legacy from a previous admin. I would really appreciate if somebody can help me and also point me to the right documentation which can help me in a future as I have a lot of inherited stuff like this in my zoo. I have tried to find how to do that reading Chef official documentation, but I guess it is something beyond the Chef itself and more Ruby stuff. |
A rails model instance, which of the following three methods would work? Posted: 06 Jan 2017 08:20 AM PST I am confused of when to add 'self.'. Does self.title call a function named 'title' or 'title' is simply a instance variable? class Movie < ActiveRecord::Base # reminder: database columns are id, title, rating, release_date # method 1: def title_with_year_1 "#{self.title} - #{self.release_date.year}" end # method 2: def title_with_year_2 "#{title} - #{release_date.year}" end # method 3: def title_with_year_3 "#{@title} - #{@release_date.year}" end end |
undefined method `attribute_method_matcher' for "":String first THEN NoMethodError: undefined method `has_key?' for nil:NilClass Posted: 06 Jan 2017 08:05 AM PST Hi I am working on a project via ruby on rails. I have my model defined as hkn_int.rb and point it to field_database table So when I in rails console, and type HknInt , it gives me the details about the table, and I type HknInt.count , it also gives me the number of items in the table, but that's the only two commands I can do without an error. If I type HknInt.first , it gives me undefined method `attribute_method_matcher' for "":String Then I type it again HknInt.first , it gives me another error NoMethodError: undefined method `has_key?' for nil:NilClass It is just weird. When I put the code on another server, it works fine. But all the configs are the same, should make no difference. Edit: Model: class HknInt < TemplateEngineModel self.table_name = 'field_database' self.primary_key = 'id' end Database Schema: HknInt(id: integer, section_id: integer, column_code: integer, created_date: datetime, date_performed: datetime, collapsed: boolean) |
Use instance method in ActiveRecord where clause Posted: 06 Jan 2017 08:22 AM PST I have an instance method that has logic I want to use in a query. My attempts have not worked. I'd rather not duplicate the logic inside is_thing when building my where clause. class Foo < ActiveRecord::Base def is_thing? #... some logic end end I tried Foo.where(is_thing?) and got NoMethodError: undefined method `is_thing?' for main:Object |
Where to define common methods to be used in services Posted: 06 Jan 2017 07:35 AM PST I can use my application_controller to define common methods that I can then use in all my controllers. I'm looking for the same idea, but for services I've created. Within my app my services folder is on the same level as models and controllers . Thanks |
No route matches [GET] "user/sign_out" rails 5 Posted: 06 Jan 2017 08:05 AM PST I am currently getting this error using Devise and I have tried multiple things from other questions in order to resolve it with ZERO luck. I was first advised to make sure I add the method as a delete: <%= link_to "Logout", destroy_user_session_path, :method => :delete, :class => 'navbar-link' %> No luck. Then I was advised that I needed to include in my layout header this: <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> or this: <%= javascript_include_tag :defaults %> Still... no luck. Lastly I was advised to change in my /config/initializers/devise.rb file to change config.sign_out_via = :delete to config.sign_out_via = :get No luck at all. I am not sure what more to try, here is my current code in my HTML, let me know if you need to see my routes to better assist you. <!DOCTYPE html> <html> <header> <h2><span>Anume*</span></h2> <img id='header' src="http://wallpapercave.com/wp/hkWe2SK.jpg" alt="" /> </header> <head> <title>Anume</title> <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> </head> <body> <p class="navbar-text pull-right"> <% if user_signed_in? %> Logged in as <strong><%= current_user.email %></strong>. <%= link_to 'Edit profile', edit_user_registration_path, :class => 'navbar-link' %> | <%= link_to "Logout", destroy_user_session_path, :method => :delete, :class => 'navbar-link' %> <% else %> <%= link_to "Sign up", new_user_registration_path, :class => 'navbar-link' %> | <%= link_to "Login", new_user_session_path, :class => 'navbar-link' %> <% end %> </p> </body> here are my rails route for the logout function: destroy_user_session DELETE /users/sign_out(.:format) devise/session#destroy |
Rails Model name conflict with included gem Posted: 06 Jan 2017 07:56 AM PST We've been mocking up our email jobs with success until we actually included our SendGrid Gem at the top of our worker require 'sendgrid-ruby' include SendGrid class Notifications::WelcomeWorker include Sidekiq::Worker def perform(email_id) emailAddr = Email.find(email_id) ... end end The problem seems to arise because SendGrid has the same model within (Email) thus generating the message undefined method `find' for SendGrid::Email:Class I've tried calling Email via ApplicationRecord::Email to be more context specific but to no avail. All the SO and other guides generally go with change our model name, but I feel like there must be a better way. To be clear we are running Rails 5 so I'm wondering if theres been an update in it to address this issue which I simply haven't found. |
action "Go Back" button breaks some css Posted: 06 Jan 2017 06:41 AM PST Faced to bug with my slider. For slider I'm using carouFredSel library. my slider has next view but when I go to other page and then click "Go Back" button (in browser) slider moves to right so "Go Back" action re-wright slider's css wrapper mayby someone also faced to same problem, how I can fix it? Thanks! |
Rails 500 error showing blank page for PUT request Posted: 06 Jan 2017 06:53 AM PST I have setup custom error pages in my rails app. application.rb config.exceptions_app = self.routes routes.rb get '404', to: 'application#page_not_found' get '422', to: 'application#server_error' get '500', to: 'application#server_error' application_controller.rb def page_not_found respond_to do |format| format.html { render template: 'errors/not_found_error', layout: 'layouts/application', status: 404 } format.all { render nothing: true, status: 404 } end end def server_error respond_to do |format| format.html { render template: 'errors/internal_server_error', layout: 'layouts/error', status: 500 } format.all { render nothing: true, status: 500} end end My custom 500 error page shows up fine when I do a GET request that throws the error but when I submit a form that triggers a NoMethodError, so a PUT request, I just get a blank page. Any ideas why the 500 error page displays correctly for a GET request but not for a PUT request? I tried changing the server_error method to def server_error render template: 'errors/internal_server_error', layout: 'layouts/error', status: 500 end but this didn't seem to help. Let me know if I can provide more code, I'm not sure how to troubleshoot this. |
How to raise ActiveResource ResourceInvalid exception? Posted: 06 Jan 2017 07:27 AM PST I want to raise an Active Resource exception manually from RSpec and I am trying to doing something like this- ActiveResource::ResourceNotFound.new(404, "Error Message") Though I am able to raise ActiveRecord exception but ActiveResource is not raising. I see the initialize method of ActiveResource is expecting two arguments. def initialize(response, message = nil) @response = response @message = message end I guess the issue is in sending the response parameter. |
Rails: How to make select field display informations from few columns and return only one Posted: 06 Jan 2017 06:16 AM PST I'm trying to make a select field that will display few informations from my db (it will be more user friendly) and return only id of chosen record. I'm not sure if it's possible to make it the "rails way" and this is why I'm writing this question. In my code I have: <%= f.select :workerid, User.where(isworker: true).pluck(:id, :last_name) %> At the moment this select is displaying only ids of users (without names) and that's really annoying me. I was trying to use .collect, or .map, but it was working the same way. It would be great if someone could show me how to display multiple columns in this select. The second thing is, if I can manage to do it, how to make it send to db only id of chosen user. I think this is possible to do in jQuery but I will be thankful if someone would tell me if I can do it in Ruby language. |
rails autocomplete: how not to make is show up in erb? Posted: 06 Jan 2017 07:44 AM PST I'm running into a very funny problem. I implemented and autocomplete function on a form field and its is working fine. This is in my add_diploma.html.erb : <%= f.fields_for :keywords do |words| %> <li> <%= words.label "Keyword : " %> <%= words.text_field :keywords, class:"field_motsclef", data: {autocomplete_source: keywords_enum_path} %> </li> <% end %> The point is that when the text fields is being filled out, the proposed terms appear in the field, BUT in the same time at the bottom of the page. I guess this is due to the fact that data: {autocomplete_source: keywords_enum_path} appears within the <%= tag. How should I do to make the result of data: {autocomplete_source: keywords_enum_path} not be displayed ? Thanks |
How to clear all caches for outgoing API requests made from my rails app? Posted: 06 Jan 2017 06:41 AM PST I have a rails app on heroku that fetches a README.md file from a github repo. I am directly fetching them using the HTTParty gem, but looks like all requests are cached if I hit the same URL. This doesn't clear unless I restart the entire rails app. I would like to be able to clear the cache so that each request I make to fetch the README.md returns a fresh result. So the question: How can I clear cache content for all requests my rails app make to external URLs? p.s. I know I should be using APIs but I am using APIs for other purposes for the same app and I am trying to minimize the usage of my APIs so I don't reach the limit. |
How to compare objects in array RUBY Posted: 06 Jan 2017 06:17 AM PST How to compare objects with the same parameter in ruby? How to define elsif part? def compare array_of_items = @items.map(&:object_id) if array_of_items.uniq.size == array_of_items.size #array has only uniq vlaues - it's not possible to duplicate object - good! return elsif #the comparision of objects with the same object_id by other param (i.e. date_of_lease param). The part I can not formulate else errors.add('It is not possible to purchase many times one item with the same values') end end |
Limit total size (MBs) of uploads per user to AWS S3 (using Shrine) Posted: 06 Jan 2017 07:06 AM PST I am working on a Rails application that allows users to upload their images to AWS S3 via shrine. The setup so far works just fine - however, I was wondering if there is any straight forward of extracting the total size of uploads per user. For example, I do want free users only to be allowed uploading max 500MB, while members get say 4GB. Haven't found anything useable on Github or Google, in general, perhaps someone can share their knowledge. Cheers ! Current code: photo.rb class Photo < ApplicationRecord include ImageUploader[:image] before_create :set_name belongs_to :employee belongs_to :user private def set_name self.name = "Photo" end end image_uploader.rb require "image_processing/mini_magick" class ImageUploader < Shrine include ImageProcessing::MiniMagick plugin :determine_mime_type plugin :remove_attachment plugin :store_dimensions plugin :validation_helpers plugin :pretty_location plugin :processing plugin :versions Attacher.validate do validate_max_size 5.megabytes, message: "is too large (max is 5 MB)" validate_mime_type_inclusion %w[image/jpeg image/png], message: " extension is invalid. Please upload JPEGs, JPGs and PNGs only." validate_min_width 400, message: " must have a minimum width of 400 pixel." validate_min_height 250, message: " must have a minimum height of 250 pixel." end process(:store) do |io, context| size_800 = resize_to_limit!(io.download, 800, 800) size_300 = resize_to_limit!(io.download, 300, 300) {original: io, large: size_800, small: size_300} end end |
rvm gemset conflicts in ubuntu Posted: 06 Jan 2017 05:04 AM PST I am facing the issue with different RVM Gemsets likewise in below. rvm list The output looks like below <<<<<<< HEAD gemsetone ======= gemsettwo c6ae09653c3440f1bdb15021def11bef59a89901 How to resolve conflicts? |
how to make all input fields to be filled before submitting Posted: 06 Jan 2017 06:49 AM PST I want to make all input field to be filled before the user submit it. I tried to disable the submit button until my input fields have been filled in. I also tried to validate on client side but could not make it work, the code passes but the button is still not enabled even when all fields are filled out. The button continues to be disabled for some reason. My _form.html.haml looks like: = simple_form_for @post, html: { multipart: true } do |f| - if @post.errors.any? #errors %h2 = pluralize(@post.errors.count, "error") prevented this Post from saving %ul - @post.errors.full_messages.each do |msg| %li= msg .form-group = f.input :title,:label => "Project Name", input_html: { class: 'form-control', :type => "text", :required => "required", :autofocus => true} %small#titleHelp.form-text.text-muted .form-group = f.input :image,:label => "Image", input_html: { class: 'form-group',"aria-describedby" => "fileHelp", :required => "required", :type => "file",:autofocus => true } .form-group = f.input :link,:label => "Project Link", input_html: { class: 'form-control', :type => "url", :value => "https://", :required => "required" , :autofocus => true, id:'url-input'} .form-group = f.input :description,:label => "Description", input_html: { class: 'form-control', :rows => "3", :required => "required" , :autofocus => true, id: 'description'} %small#descriptionHelp.form-text.text-muted %button.btn.btn-info{:type => "submit", :disabled => "disabled" } Add Project I have tried this in application.js $('#url-input, #description').on('blur keypress', function() { var urlInputLength = $('#url-input').val().length; var descriptionInputLength = $('#description').val().length; if (urlInputLength == 0 || descriptionInputLength == 0) { $('button').prop('disabled',true); } else { $('button').prop('disabled',false); } }); I feel that my js is not connecting to my html code for some reason. Also, I am wondering if there is any other way to make it work without JS. Thank you in advance! |
How to use Gitlab CI to deploy a Showoff application on Heroku Posted: 06 Jan 2017 04:49 AM PST I have successfully deployed a showoff presentation on Heroku. Because Heroku makes it so easy to integrate Github, I have also been able to add a Github repository that auto-deploys on Heroku. I want to setup the same thing in Gitlab. Can someone please help me in setting it up? the app.json used by Github is as follows: { "name": "lunar-teach", "scripts": { }, "env": { "LANG": { "required": true }, "RACK_ENV": { "required": true } }, "formation": { }, "addons": [ ], "buildpacks": [ { "url": "heroku/ruby" } ] } |
how to Tokenize payfort merhant page 2 while integrating with rails application? Posted: 06 Jan 2017 04:36 AM PST I'm Integrating my rails application with payfort using payfort api merchant page 2.0 I've made a form that collects user data and in my back end I do calculate the signature so the result is like this ` parametsrs ={ :access_code=>"4XiE5d2D9Yvbbb9YMYPE", :card_number=>4005550000000001, :card_security_code=>123, :expiry_date=>1705, :language=>"en", :merchant_identifier=>"MpFMkQYk", :merchant_reference=>139, :service_command=>" TOKENIZATION" :signature => "d0f49bf93d76939dd9f841302f4d6ca87151a54ceffca725b38cdaf9a1a2fdb0"} ` but whenever I submit this form I got this response invalid extra parameters can anyone help me with that? |
Agile rails development book, Depot rake test 2 errors Posted: 06 Jan 2017 04:44 AM PST I'm have been trying to solve this issue for a while now, but without any luck. I'm going thru the Agile rails developmnet book and when I run rake test I get 2 errors at Iteration B1 Validating: Error: ProductsControllerTest#test_should_create_product: URI::InvalidURIError: bad URI(is not URI?): http://www.example.com:80create test/controllers/products_controller_test.rb:26:in `block (2 levels) in <class:ProductsControllerTest>' test/controllers/products_controller_test.rb:25:in `block in <class:ProductsControllerTest>' Error: ProductsControllerTest#test_should_update_product: URI::InvalidURIError: bad URI(is not URI?): http://www.example.com:80update test/controllers/products_controller_test.rb:43:in `block in <class:ProductsControllerTest>' Can someone please help me solve this!!! Products>controller_test.rb require 'test_helper' class ProductsControllerTest < ActionDispatch::IntegrationTest setup do @product = products(:one) @update = { title: 'Lorem Ipsum', description: 'Wibbles are fun!', image_url: 'lorem.jpg', price: 19.95 } end test "should get index" do get products_url assert_response :success end test "should get new" do get new_product_url assert_response :success end test "should create product" do assert_difference('Product.count') do post :create, product: @update end assert_redirected_to product_url(Product.last) end test "should show product" do get product_url(@product) assert_response :success end test "should get edit" do get edit_product_url(@product) assert_response :success end test "should update product" do put :update, id: @product, product: @update assert_redirected_to product_url(@product) end test "should destroy product" do assert_difference('Product.count', -1) do delete product_url(@product) end assert_redirected_to products_url end end products_controller.rb class ProductsController < ApplicationController before_action :set_product, only: [:show, :edit, :update, :destroy] # GET /products # GET /products.json def index @products = Product.all end # GET /products/1 # GET /products/1.json def show end # GET /products/new def new @product = Product.new end # GET /products/1/edit def edit end # POST /products # POST /products.json def create @product = Product.new(product_params) respond_to do |format| if @product.save format.html { redirect_to @product, notice: 'Product was successfully created.' } format.json { render :show, status: :created, location: @product } else format.html { render :new } format.json { render json: @product.errors, status: :unprocessable_entity } end end end # PATCH/PUT /products/1 # PATCH/PUT /products/1.json def update respond_to do |format| if @product.update(product_params) format.html { redirect_to @product, notice: 'Product was successfully updated.' } format.json { render :show, status: :ok, location: @product } else format.html { render :edit } format.json { render json: @product.errors, status: :unprocessable_entity } end end end # DELETE /products/1 # DELETE /products/1.json def destroy @product.destroy respond_to do |format| format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_product @product = Product.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def product_params params.require(:product).permit(:title, :description, :image_url, :price) end end products.rb class Product < ApplicationRecord validates :title, :description, :image_url, presence: true validates :price, numericality: {greater_than_or_equal_to: 0.01} # validates :title, uniqueness: true validates :image_url, allow_blank: true, format: { with: %r{\.(gif|jpg|png)\z}i, message: 'must be a URL for GIF, JPG or PNG image.' } end |
How to create migration script for has_many, belong_to association between user and task model in ruby Posted: 06 Jan 2017 05:58 AM PST I have two model User and Task. Task would have one owner and other as workers. class Task < ApplicationRecord belongs_to :user has_many :user end class User < ApplicationRecord has_many :user end how write its migration script. i dont know much about ruby so please correct if i am wrong. |
How to ensure that a big file (blob) is released from memory in ruby? Posted: 06 Jan 2017 04:34 AM PST I have an app which receives an incoming file (attachment in the form of blob_data), and just passes it on, to another external service/API (while storing the attachment metadata in my app). I don't need to store the blob_data in my app. class Attachment < ActiveRecord::Base attr_accessor :blob_data end When I call @attachment.save I presume the blob_data won't be persisted to the DB, because it is an attr_accessor field. But, is there a way to ensure that this blob_data is released from memory immediately? I don't want the blob_data lingering around until the GC catches it at a later time, as it may take up quite a bit of memory, especially if the server receives several requests in the same time period. Would it be as simple as using @attachment.blob_data = nil ? Will this have any effect on the immediacy of the GC catching it? Is there a better way? |
Rails factory girl create with multiple models(sti) Posted: 06 Jan 2017 05:45 AM PST I have factory Rule which is parent for my other factories parent is regular model class Rule < ActiveRecord::Base belongs_to :fee end class Fee < ActiveRecord::Base has_many :rules end FactoryGirl.define do factory :rule do type { rule_classes.sample } name { SecureRandom.hex } data '["name"]' association :fee, factory: :fee end my children rule models looks like AirlineRule < Rule factory :airlines_rule, parent: :rule, class: 'AirlinesRule' do data "airlines": ["KL","PN"] end but now i want to create Fee's factory fee_with_all_rules is it possible? i have tried factory :fee_with_all_rules do association :fee, factory: [:airlines_rule, :connections_rule] end but it doesn't work |
Gem for Send/ Receive e-mails in Rails 4 admin panel Posted: 06 Jan 2017 04:07 AM PST Basically, I am searching for advise to choose best gem for Sending/Receiving e-mails in Rails 4 admin panel. Main requirement would be that gem can't be for specific domain e-mails like Gmail, Yahoo and etc. At this moment I found mikel/mail What you think of this gem ? Or can you suggest better one ? Thanks in advance. |
After installing only rails gem version 5.0.0, the command 'rails -v' prints 'Rails 5.0.1'. Why? Posted: 06 Jan 2017 04:41 AM PST I need to stick with Rails 5.0.0 for now. I'm using a gemset (rails500) and ruby-2.3.3 with rvm. I told rvm to use the gemset and uninstalled the other Rails version (5.0.1) from it using the command 'gem uninstall rails' then the command 'gem install rails --version=5.0.0'. Now when I do a 'rails -v' the response is 'Rails 5.0.1'. Why isn't it 'Rails 5.0.0'? When I do a "gem list | egrep '^rails '" the response is 'rails (5.0.0)'. Related question: how can I be sure this version of rails is not 5.0.0? |
Have buttons inline with a form Posted: 06 Jan 2017 03:31 AM PST I'm working on a project where I need to make a sort of date picker. To do this I want to have a forward and back button, with a form containing a hidden field in between. However when I do this the buttons end up on top and below the form. My code is as follows: <span style="display: inline;"> <button class = 'btn btn-primary btn-xs'><%= back %></button> <%= form_tag year_path, class: "form-inline", remote: true, method: :put do %> <%= @year %> <% end %> <button class = 'btn btn-primary btn-xs'><%= forward %></button> </span> How do I make it so that the buttons appear on either side of the year? |
Rails_Admin related dropdowns Posted: 06 Jan 2017 02:54 AM PST Is there a way to filter a dropdown list based on another dropdown's value ? For example, if we have: Class and Student Models where Student have class_id ; is there a way to filter the Students shown in the dropdown based on the selected Class ? |
Ruby 2.4 and Rails 4.0.8 stack level too deep (SystemStackError) Posted: 06 Jan 2017 03:08 AM PST I'm trying to run newly created project in Rails 4.0.8 but I receive and error: rails s => Booting WEBrick => Rails 4.0.8 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated Exiting /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:124:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError) from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' ... 5532 levels... from /usr/local/lib/ruby/gems/2.4.0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `tap' from /usr/local/lib/ruby/gems/2.4.0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>' Ruby version: Rails 4.0.8 My Gemefile: source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.8' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.2' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 1.2' gem 'json', github: 'flori/json', branch: 'v1.8' group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end I tried to reinstall rails because before I have 5.0 Rails installed on my machine. Local gems: *** LOCAL GEMS *** autoprefixer-rails (6.6.0) coffee-rails (4.2.1, 4.0.1) font-awesome-rails (4.7.0.1) jquery-atwho-rails (1.3.2) jquery-rails (4.2.2, 3.1.4) rails (4.0.8, 4.0.0) rails-dom-testing (2.0.2) rails-html-sanitizer (1.0.3) rails_12factor (0.0.3) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) sass-rails (5.0.6, 4.0.5) sprockets-rails (3.2.0, 2.3.3, 2.0.1) Meybe unistall: ruby and rails will solve this problem, but I dont want to do that. Beasically I whant to have installed both version of rails, for exampole: rails 4 and rails 5 as well. Is that configuration possible ? |
running app at heroku for the first time and got An error occurred in the application and your page could not be served Posted: 06 Jan 2017 05:07 AM PST I deploy a rails app for the first time in heroku but I got this kind of error 2017-01-06T10:26:15.630113+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=salty-brook-61028.herokuapp.com request_id=bdcee548-bb75-4ac0-a3fe-96bc16adaf32 fwd="112.198.103.230" dyno= connect= service= status=503 bytes= 2017-01-06T10:26:17.045896+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=salty-brook-61028.herokuapp.com request_id=37217afd-7781-4f64-8ba3-fc2ad724a4d0 fwd="112.198.103.230" dyno= connect= service= status=503 bytes= trying to visit the app and it display this message An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. This is the log result using the command heroku logs --tails 2017-01-06T11:29:39.413191+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=salty-brook-61028.herokuapp.com request_id=b47de71b-b562-4afd-8625-7082098f25f9 fwd="112.198.73.169" dyno= connect= service= status=503 bytes= 2017-01-06T11:29:41.018749+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=salty-brook-61028.herokuapp.com request_id=f408aa4e-2bab-4a48-9404-56b47ed5e1a9 fwd="112.198.73.169" dyno= connect= service= status=503 bytes= 2017-01-06T11:58:05.415446+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=salty-brook-61028.herokuapp.com request_id=0cf9d492-8e32-49b7-8166-6e983d3442d7 fwd="112.198.73.169" dyno= connect= service= status=503 bytes= The application.rb require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module MySecondApp class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. end end The production.rb Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "my_second_app_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end` database.yml # SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' # default: &default adapter: sqlite3 pool: 5 timeout: 5000 development: <<: *default database: db/development.sqlite3 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: db/test.sqlite3 production: <<: *default database: db/production.sqlite3 please help me on this. |
No comments:
Post a Comment