JQuery File Upload with Ruby on Rails/brackets - ruby-on-rails

I was interested in JQuery File Uploader on Ruby on Rails and tried to use this applicationm and this one
I have made a new rails project with "rails new fily" and have copied and pasted all files in my fily-folder that they have in this application. I run bundle install and rake db:migrate but by opening localhost:3000/picture the only thing that I saw was: [], brackets and nothing more. What can be the reason?
In terminal I see following:
Started GET "/pictures" for 127.0.0.1 at 2012-10-21 23:21:13 +0200
Processing by PicturesController#index as HTML
Picture Load (0.2ms) SELECT "pictures".* FROM "pictures"
Completed 200 OK in 3ms (Views: 1.6ms | ActiveRecord: 0.2ms)
[2012-10-21 23:21:14] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
I would be grateful if somebody helps me
PS. I have found as well some very strange hidden file there:
.rvmrc
with a content:
rvm use ruby-1.9.3-p194#fily
What should that mean?

The .rvmrc file is used by RVM, the Ruby Version Manager, which allows multiple versions of Ruby to coexist on a machine, and allows you to specify which ones to use. The .rvmrc tells RVm to use the specified version of ruby, although it seems to me that the person who made that git repo used his own compiled from source. I don't think deleting it will bring any harm.
Looking at the code, (haven't got ruby on this machine yet so I can't test it to be sure), it seems as though you shouldn't be accessing /pictures. Instead, just access / (which calls and renders the pictures#new controller).

Related

How to fix NoMethodError undefined method `escape' for URI:Module?

I'm following this guide for implementing the PayPal REST API in my Rails app, and it gives an error that's said in the title, specifically pointing to this line in the code under create_order.
response = #client.execute request
I'm sure I have my client id and secret copy pasted and I also copy pasted most of the code to avoid any errors. What's causing this problem and how do I fix it? I appreciate the help.
Edit:
Command line output:
Started POST "/create_order" for ::1 at 2021-11-16 21:21:07 +0800
Processing by BookingsController#create_order as */*
Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms | Allocations: 1603)
NoMethodError (undefined method `escape' for URI:Module):
app/controllers/bookings_controller.rb:35:in `create_order'
Probably best to just do a monkey patch with future expectation of moving away from paypal-checkout-sdk (it's deprecated)
monkey patch option can be found at:
paypal-checkout-sdk breaks in ruby 3.0.1
you are missing gem files which are required to use the URI.escape
add these gems in you gemfile
gem 'uri'
gem 'net-http'
gem 'http'
after that
run command => "bundle install" in the terminal
and then try to run you application via rails s
hope this will fix your error
Since "URI.escape" is depriciated by the ruby community but "paypal-checkout-sdk" uses it while requesting from client.
which is like this: #client.execute request

Rails on EC2 - Puma responds, but page never loads on browser

Firstly, cheers! This is my first post here on Stack Overflow, I'll try not to do anything silly :). I've spent the last 3 days banging my head against this issue and googleing away, but never really found a solution, however basic it may be.
I've set up a fresh EC2 instance (running Ubuntu 16.04) and created a new Rails (v 5.1.6) app with a simple scaffold:
rails new test_app
cd test_app
At this point, Rails complained that I had to install the 'listen' gem, which I did (v 3.1.5). I then proceeded as follows:
rails g scaffold article title:string
rails db:create
rails db:migrate
So far so good. I then went on to configure AWS's security groups and properly allow TCP connections through port 3000. I'm currently using Puma (v 3.7) as a server.
Here's whats bugging me: I then ran
rails server
and tried to connect to my EC2 through Chrome on port 3000. Turns out that I was able to get to the usual "You're on Rails" page, no problem, but when I tried to get to any other pages, say /articles or /articles/new, I got a positive response from the server in the console:
Started GET "/articles"
Processing by ArticlesController#index as HTML
Rendering articles/index.html.erb within layouts/application
Article Load (0.7ms) SELECT "articles".* FROM "articles"
Rendered articles/index.html.erb within layouts/application (47.3ms)
Completed 200 OK in 3912ms (Views: 3807.5ms | ActiveRecord: 1.5ms)
But the browser keeps waiting forever for a response. I also tried accessing the URL through curl and got no response as well. I'd appreciate if anyone could let me know how stupid a mistake I'm making here.
Thanks,
Márcio
Firstly, cheers you explained your problem very well
when you deploying your app on EC2 then this isn't the right way to do but still it should give you response in browser. Please make sure your port 3000 isn't blocked. Go to network interface -> select your instance carefully -> in front of Security groups check your inbound rules and make sure port 3000 is open
Above explanation is just to answer whatever you are trying to do. Although this should not be the proper way. Proper way should (in short ) be running your ruby on rails application with a rack server (puma, thin, etc) behind a web server Apache or Nginx .

Why default page is calling even though index.html.erb file in public folder is missing?

I am developing a simple ruby on rails app.The server has started successfully.Then when we go to the default web url localhost:3000/ the default route is called showing the home page about the instructions.But we dont want this so need to remove the index.html.erb file in the public folder under the main project directory.The real problem is the file is missing and still the default page is loading.
What is really happening here and where is the index.html.erb file located.[Dont Mark it Duplicate because here the problem is different].How to call another route to show some mypage.html
Server Log
Started GET "/" for ::1 at 2016-04-19 23:29:26 +0530
Processing by Rails::WelcomeController#index as HTML
Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/templates/rails/welcome/index.html.erb (0.0ms)
Completed 200 OK in 36ms (Views: 35.1ms | ActiveRecord: 0.0ms)
Files in public folder:
400.html
422.html
500.html
favicon.ico
robots.txt
Add root to your routes.rb
root 'MyController#my_action'
You want to set your home root for your application. Just pick another route, example below.
root 'static_pages#home'
Found this soluton Link here
Coffee script 1.9.0 doesn't play well with Windows. On my Windows 7 machine, using version 1.8.0 solved this problem.
Add to Gemfile
gem 'coffee-script-source', '1.8.0'
then, run
bundle update coffee-script-source
and restart the server (if needed)

Ruby on Rails | AirBrake Error

Trying to run a project that was provided by a client.
I have the correct versions of Ruby, Gems, Rails, Bundler, Homebrew etc installed.
When I run rails server I get the following error in terminal.
.rvm/gems/ruby-2.2.2/gems/airbrake-ruby-1.0.4/lib/airbrake-ruby.rb:288:in `call_notifier': the 'default' notifier isn't configured (Airbrake::Error)
After much time spent on Google I couldn't find a fix on this.
Here is a screenshot of the whole terminal error message which I get the feeling these other lines could be related.
It looks like a previous developer may have hardcoded a commit hook in the application, pointing to a file in their local .git folder (and which you don't have).
I'd recommend either asking the developer to provide the missing file, create a dummy file in the same place, or removing that line.

RoR - Not loading or requesting -any- assets in development mode

I'm brand new to Rails development and in a bit of a mess! I've been given a codebase and none of the assets aren't being referenced in the HTML. No failed network requests, they simply aren't being included in the mark-up! They are present there when I attempt to access them directly using their URL though.
As a comparison - my colleagues system ends up with around 30 or so requests and the end result is fully styled. However I have no styling and just the base mark-up.
I've done a fair amount of reading and checked my config, checked that I'm running in development mode and so on. I'm really stumped!
For what it's worth, I'm currently working in a cross-platform team environment where there are developers using Linux, Windows and Mac OS X. No one has these issues; and I'm pretty sure the other developer using Mac OS X has his set-up exactly the same as mine!
The source code was acquired from the same git repository as others, and it's definitely up to date. Below is the output from rails: note no errors.
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: /******************/abstract_store.rb:28:in `initialize'.
[2013-04-17 21:20:55] INFO WEBrick 1.3.1
[2013-04-17 21:20:55] INFO ruby 2.0.0 (2013-02-24) [x86_64-darwin12.3.0]
[2013-04-17 21:20:55] INFO WEBrick::HTTPServer#start: pid=22421 port=3000
Started GET "/" for 127.0.0.1 at 2013-04-17 21:21:05 +0100
Processing by AccountsController#home as HTML
Completed 401 Unauthorized in 6ms
Started GET "/users/sign_in" for 127.0.0.1 at 2013-04-17 21:21:05 +0100
Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.erb (1.5ms)
Rendered devise/sessions/new.html.erb within layouts/application (10.0ms)
Rendered layouts/_navigation.html.erb (1.0ms)
Rendered layouts/_messages.html.erb (0.3ms)
Completed 200 OK in 776ms (Views: 86.5ms | ActiveRecord: 647.5ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-04-17 21:21:06 +0100
Served asset /application.js - 304 Not Modified (1ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-04-17 21:21:06 +0100
Served asset /application.css - 304 Not Modified (1ms)
Note: The application.js just appears to have 5 //=require directives; and the application.css has mainly comments with a few simple rules - nowhere near what should be there.
My solution is: install ruby version 1.9.3 and set this version as default. Restart your computer. Then install rails 3.2.6. Then clone a new repository for your source code (Do not reuse the one that is having error). Run bundle install.
Before this, I also tried to install ruby 1.9.2 with rvm but it does not work. Then I tried with ruby 1.9.3 and it works.
I've had a similar problem in a previous project. Personally I would try what everett1992 said because if that corrects the problem, it's probably best. But what I've used when that didn't work was the line
config.assets.prefix = "/assets_dev"
to my development.rb file.
Now, assets_dev is not a real directory, I never created it. But it forced rails to look there, and then when it doesn't see it, rails will load your assets from the default location as should happen in rails.
Like I said, it might work, but I'm sure its not the best way. I too work on OS X on cross platform projects with others, and I've yet to figure out why this sometimes happens.
I'm using mac os x 10.6.8 and I have the same problem, and tried all the solutions above. Nothing work.
Including:
1> update gem
2> remove rvm, reinstall rvm, ruby, rails...
3> and make configuration as config(dot)assets(dot)prefix = "/assets_dev"
By the way, I've checked GoogleChrome console, and realize that, within application(dot)css, there is still statement as below:
require_self
require_tree.
Which mean these reference does not works at all.
The same things happen to application(dot)js
P/S: I'm using rails 3.2.6

Resources