I am following the tutorial at Ember and Rails 5 with JSON API: A Modern Bridge.
Thus, I now have a rails-api for backend and ember for front end. I started the rails server as suggested:
$ bin/rails server --binding 0.0.0.0
Started the ember server:
$ Ember s --proxy --http ://localhost:8080 --port 8081
I had to specify a port for creating the Ember server though, because I got an error saying:
Port 8080 is already in use
It seems as the rails backend work as if it is suppose to. When I visited http://localhost/something.json I get the proper json response.
In the tutorial they ask you to visit the ember frontend open ember inspector, console and enter the command :
$E.store.findAll('book');
The response I get is:
Uncaught TypeError: Cannot read property 'findAll' of undefined(…)
I am using c9 with this tutorial, not sure if it has anything to do with it though.
The question is, Why am I getting this Error?
I Am new to stackoverflow, Rails and Ember.
I have searched the question and the solutions posted did not work for me.
To access the store, you have to use getters.
Like:
this.get('store').findAll('book');
Because the store is a service and lazy-loaded.
Related
I'm new in Laravel and I would like to ask for guidance for the datatables tutorial.
I tried to follow the laravel datatables tutorial from the link I provided below and I kept on encountering the issue below.
Laravel Datatables Link:
https://appdividend.com/2018/04/16/laravel-datatables-tutorial-with-example/
DataTables warning: table id=table – Ajax error. For more information about this error, please see http://datatables.net/tn/7
I tried to change the providers and aliases from the config as instructed. I also went to the Web Developer > Network by clicking ctrl+shift+E in firefox, I went to xhr and I saw that its returning 500 Internal Server Error. Could you please guide me on how to fix this.
I am using php artisan serve to run the web page as instructed on the tutorial but according to the github link the artisan serve should be avoided.
github link: https://github.com/yajra/laravel-datatables
I have a Rails 4 application with nginx 1.4.4 and I'm having issues trying to access JSON routes.
I'm trying to access the following route:
http://www.example.com/products/106.json
Which produces a 404 / Not found in my nginx server. However, in my development server it works correctly (a Thin server), it displays the product as JSON.
I have already added the application/json json; line to the mime.types config file.
What else should I look in order to fix this? I can provide more information if needed. Thanks.
in ruby on rails console 'net/http' works, but in controller it doesn't and gives timeout error.
require 'net/http'
uri = URI('http://localhost:3000/api_json.json')
json = Net::HTTP.get(uri)
parsed_json = ActiveSupport::JSON.decode(json)
Most likely you're using default Webrick server, that serves one request a time. So, from console it works fine, but fails when you try to call it from controller (when the Webrick worker is already busy).
You can try to setup and run another server like unicorn or thin, or run two Webrick instances on different ports:
rails server
rails server -p 3001
and go to localhost:3001
#dimuch's solution might have solved your issue, but it might help someone facing similar situation. I will explain the issue, and the solution in detail (extension of #dimuch's solution).
Issue:
You might have a controller like some:"/test_controller/test_method", and you might want to call a method in a controller, like /api/v1/some_test_api, and facing error like Completed 500 Internal Server Error in 60004.4ms
[27580c5c46770812c550188346c2dd3e] [127.0.0.1] [/xauth_test/sanity_oauth_login]
Timeout::Error (Timeout::Error):
Solution:
As said by #dimuch, "
Most likely you're using default Webrick server, that serves one request a time.....". 1. You need to run the application on different ports, like
rails s -p 3000, and rails s -p 3001, then make the request from 3001.
If you face an issue like "A server is already running. Check /tmp/pids/server.pid. Exiting", then try running rails s -p 3001 -P PROCESS_ID.
2. Use other server's like Unicorn, or Puma.
Note: If you want it for just testing purpose in local, then I would suggest to go with the first solution, which is easy and simple. I am sorry for poor English, and I found most of solutions from other stack overflow pages, and websites, which I am attaching (links for refs) below, and sorry if I missed some one or some thing to refer. Hope this helps someone.
Refs:
For running multiple instances:
Running multiple instances of Rails Server
Similar errors and way they are handled:
Rails HTTParty Getting Timeout::Error
Faraday timeout error with omniauth (custom strategy)/doorkeeper
Strange Timeout::Error with render_to_string and HTTParty in Controller Action
Configuring Unicorn &Puma:
http://vladigleba.com/blog/2014/03/21/deploying-rails-apps-part-3-configuring-unicorn/
https://github.com/puma/puma
As I'm newbie in Rails ,So is there any document which help me to understand the internal process of commands. Like when I use
$ rails server , so I need to understand what the process going behind the scene and how its started webric server and create a deameon IP if I used option $ rails server -d 198.0.0.0 etc..
Railties is what takes care of the command line interface, including rails server.
This file should be your entrypoint: https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server.rb
You can see the default options and the option parser implemented in there.
However, if you want to dig deeper in how Rails communicates with the server, you should study Rack, since Rails is after all a Rack app.
You can watch through all of these screencasts and documentation from Rails Guide.
http://guides.rubyonrails.org/initialization.html
http://www.bigbinary.com/videos/2-how-rails-boots
http://railscasts.com/episodes/299-rails-initialization-walkthrough
Hey, Guys
I'm now learning starting up the Rails on my VPS server, Now I can visit my app rails my thin server by a 3000 port number, something like this http://mydomain:3000,
But I want to map this app to the url like http://mydomain/railsapp1, so when I add a railsapp2 for testing purpose, it won't mess up my railsapp1.
Should I add something in the thin configuration file? or I should use nginx?
Are you open to using Passenger (ModRails)? You could then use Nginx and setup your Rails apps under different subdirectories.
General information for installing Passenger in Nginx can be found here: http://www.modrails.com/install.html
You can see more information here on setting up Rails in subdirectories: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_rails_to_sub_uri
You could just start railsapp2 on port 3001 if you want to have both running at the same time
Rails 2
script/server -p 3001
Rails 3
rails server -p 3001