I have an Angular Application (Angular 5) as well as Ruby on rails backend. I put my angular app in the ruby-on-rails public folder and its working fine with a '#' prefix.
Now, I want to remove that '#' Prefix. When I remove it, I am getting errors.
I've deploy ruby-on-rails application on EC2 with Apache2 and Passenger.
This is my PATH for .htaccess file
/var/www/ro-blog/.htaccess
Can anyone please help me - How can I fix that?
My situation is that I have just finished creating a blog using ruby on rails. I have been using localhost to see it display on my browser, but I want to deploy it online. I found out that rails apps can't be deployed on ghpages because it is not static. However, I searched online and read that if I used Jekyll, i could display it on ghpages. I have never used jekyll before, so my question is...
How could I use/integrate jekyll to my existing rails app so that it can be deployed and hosted through github pages?
Thank you!
You are trying to screw in a screw with a hammer.
Github pages is simple free hosting for static pages like a simple portfolio or the info page for a github project. You would use jekyll to generate simple static HTML pages for this.
If you want to deploy a Rails application there are several cloud hosting providers such as Heroku and Openshift that provide a free tier.
First determine what you are trying to build. Then select the right tool and hosting for the job.
You CANNOT host a rails blog app with databases on gh pages. you need a static site to be hosted on ghpages. jekyll is a static site generator that generates static HTML pages which can be served to users from gh-pages.
So you need to build new blog engine with jekyll
install jekyll: gem install jekyll
create new jekyll site: jekyll new your-github-username.github.io
cd to the new directory generated and test locally: jekyll serve (visit http://localhost:4000)
link to github articles on gh-pages with jekyll
I have a complete ruby project on my system that I downloaded from github.com and I want to run it on my Windows machine.
I have already installed Ruby and Rails on my system, but I have no idea how to run this project. The directory of this project is something like:
C:\Users\{username}\Desktop\BitcoinFundi\BitcoinFundi
How would I run this project on my system?
To run your Ruby on Rails application, use the following command:
rails server
This will start the server and you will be able to access the application in your browser at http://localhost:3000. Port 3000 is default and you can change it in the application settings.
To run a Ruby script use:
ruby name_of_script.rb
You should check out various resources and tutorials on getting started with rails.
As you say in your comment this is your first experience with Ruby on Rails, I think you should follow through chapter 1 and 2 (at least) of Ruby on Rails Tutorial. After that you should have a better understanding of how you start up a rails app and configure the DB. You also need a bunch of other libraries and software such as mysql from the sounds of it.
You should also read Getting Started with Rails. Section 4 covers how to start the default rails server.
Here is a guide on setting up a Rails environment for Windows, which is one of many guides, that shows you some of the needed steps to get a fully working environment.
I've been long time investigating how to generate complex .pdf files (many images and 30 pages aprox). from a html web, of my rails application.
At the end I realized than the best option is wkhtmltopdf from command line.
using pdfKit gem don't work in production, but it works in development
using wkhtmltopdf from command line, works in development but neither in production.
I have read a lot of issues with wkhtmltopdf, so I abandon use wkhtmltopdf getting info from production web server. --> Instead I have created a new environment "genera_pdf" to run in production database, with development configuration (assets, cache..etc)
And now I need to run some proces than execute this:
1) RAILS_ENV=genera_pdf rails s
2) wkhtmltopdf localhost:3000 result.pdf
3) stops (CTRL+C) rails s
If this is achievable, Whats the best way to do this in Linux?
I'm absolutly missed...with rake tasks? or rails runner? or Cron-task?
Thanks a lot
I know in PHP you have to intrepret a page like index.php, but in Ruby how does it work? I don't know what is the Ruby extension like index.php for PHP. Could you help me?
If you are talking about a command line program this will work.
puts "Hello World"
or if you want an object oriented version
class HelloWorld
def initialize(name)
#name = name.capitalize
end
def sayHi
puts "Hello #{#name}!"
end
end
hello = HelloWorld.new("World")
hello.sayHi
If you are looking for a ruby on rails version of Hello World.
Check the Getting Started Guide for Rails.
You can take a look at this Ruby Programming Wiki on Wikibooks
Code:
puts 'Hello world'
Run:
$ ruby hello-world.rb
Hello world
This is how to write a very simple "hello world" using Sinatra, which is a great way to bring up a Ruby-based website without using Rails. The sample is basically the same as the Sinatra folks have on the front page of their site. It's really this simple.
Install the Sinatra gem along with its dependencies:
`gem install sinatra`
Save this to a file called hi.rb:
require 'sinatra'
get '/hi' do
"Hello World!"
end
Drop to the command-line, and enter ruby hi.rb. After a few seconds you should see something like:
== Sinatra/1.1.0 has taken the stage on 4567 for development with backup from WEBrick
[2010-12-04 11:43:43] INFO WEBrick 1.3.1
[2010-12-04 11:43:43] INFO ruby 1.9.2 (2010-08-18) [x86_64-darwin10.5.0]
[2010-12-04 11:43:43] INFO WEBrick::HTTPServer#start: pid=37898 port=4567:
By default Sinatra serves its pages at port=4567, but you can change it. Read the docs to learn how.
Open a new window in your browser, and go to:
http://localhost:4567/hi
and you should see Hello World! in your browser window.
Sinatra is really easy to work with, and makes a great prototyping and light-to-medium weight MVC-like server. I love it because of its easy integration with Sequel, my favorite ORM, and HAML, which replaces ERB as the templating engine.
Sinatra's Intro doc is a great starting point. The Sinatra Book is a good resource too.
How does it work in Ruby?
Ruby is a scripting language (not compiled) just like php (as you said "you have to intrepet a page") and python, bin/bash, etc...in Ruby you have libraries with helpers and very very cool stuff they are called "gems" (Ruby and Gems :D nice name convention right? BTW this is because Ruby's parent is Perl).
You can organized different files inside one Ruby's project folder, it could be in this case one *.rb file and one "Gemfile" (that's the name without extension) in which you define which "gems" you want to install in your Ruby app (read about bundler), only with this two files you will be able to successfully do anything you want but as a desktop app (by this i mean that the Ruby app you write will only be executable on a computer with Ruby installed, and you have to install it manually (with bundler so all required "gems" are in there) and then manually run Ruby's command targeting your code's main class (unless of course you create a cron-job that do this automatically for you, pretty common practice to run processes on web servers).
If you want to use Ruby to create a "webapp" , website , etc right now two pretty popular choices are using the "rails" framework and "sinatra" gem.
With rails (that's why you hear much about ruby on rails) framework you are able to execute commands to create new website project, remember that rails uses the coding pattern called MVC (model view controller) so you will have plenty options for creating your models, views and controllers individually or using "scaffold" that will create all of them for you, rails will create a bunch of files and some of them will not be *.rb of Gemfile, all of them will have a specific task: configuration files for database, labels, of config or other "gems" you install besides rails.Take in mind that rails offer stuff for TDD (test driven development) so in a matter of hours you can have a fully functional website 100% tested and operational (big infrastructure).
This is why i also brought "sinatra" gem to this conversation...sinatra will give you same functionality than rails does but instead sinatra will not install anything for you (leaving space for error if you have not expertise on setting on web servers, web apps , etc) only the sinatra framework which will run a server for you on a specific port number so that way you can then add code to your main class in order to display HTML(small infrastructure)
What is the Ruby extension like index.php for PHP?
All ruby files are using *.rb
Hope this helps!
PS: Hello world sample
install ruby
create a new folder an inside create a file "hello.rb"
open the file and add the following code:
puts 'Hello world'
close and save the file
now open a terminal, console, etc go to your ruby file folder path and run the following command:
ruby hello.rb
that will print on your console:
Hello world
puts "Hello, World!"
To run Ruby scripts on the web, you need to use a special server, run through (F)CGI, or do some other stuff; there are several ways to get different languages HTTP-accessible. However, the simplest way is probably to use a Ruby web framework, such as Ruby on Rails or Merb -- these projects include servers and all of the things you need to get going.
Just copy and past this code on your terminal. Then hit enter.
ruby -e "puts 'Hello world'"
I know the question was talking about Ruby, but I think you meant rails (which is what it was tagged as). Rails is a web framework that uses the ruby programming language.
install rubyonrails.
Type:
rails projectname
cd projectname
ruby script/server
Navigate to http://localhost:3000