Rails demo app on local host not working - ruby-on-rails

New to Rails. Everything solid through creation of demo_app, but rails server is yielding just the basic rails welcome page, not my demo application

You need to delete public/index.html and change root to: in config/routes.rb to point to your welcome page's controller action.

Well, then Rails works :)
In your console cd to the Folder where your rails app is and run
rake routes
Then try out one of the routes in your browser.
If there aren't any, you have to create routes. Follow some tutorial for this.

Related

How to quickly add a Wordpress blog to an existing RoR app without writing a custom blogging ror app

This question is related to Creating a Blog in an Existing Ruby on Rails app, but it doesn't have the answer I am looking for.
I have put a blog folder in my existing ror app's public with a hope that I can get to my blog by http://example.com/blog or during local test I could access it through http://localhost:3000/blog (localhost:3000 where I can access my original app)
But, I get following error
Routing Error
No route matches [GET] "/blog"
Try running rake routes
What line should I add my routes.rb or vhost files on server to get what I want?
The blog folder has fully functional wordpress blogging system.
I am not a Ruby on Rails expert, the app was created by someone else, I was looking for some quick work around to add the blog.
I certainly don't want to create a subdomain http://blog.example.com
The problem with running Wordpress inside a Rails app is that Wordpress runs on PHP. I'm not sure if there is an elegant solution for serving PHP inside Rails (you may just be able to point Apache to the directory inside your Rails app, I don't know), but it seems like a bad idea, or at least a huge pain.
What I would do is serve your Wordpress blog along side your Rails app (so you've got a PHP and a Rails server running), and just have your /blog route point to a controller that redirects to your Wordpress app. Add something like this to your routes.rb:
get '/blog', to: 'blog#redirect'
and then have a redirect method in your BlogController that simply does this:
class BlogController < ApplicationController
def redirect
redirect_to "url_of_wordpress_blog"
end
end
Now you can point at yourdomain.com/blog and it will take you to the Wordpress site.

Rails Server, new files not live

I'm going through a Ruby on Rails tutorial and right now it's generating controllers. (I believe I'm on the local server.. started by doing:
$rails s
When I look in TextMate, all the new files have a "no entry" sign on them, which I assume to be not live. They also don't work when I try to pull up the address.
How do I make them live?
(Edit: Picture added, also.. When I try to go to the page it says:
Routing Error
No route matches [GET] "address"
Try running rake routes for more information on available routes.
Rails should not be generating controllers.
My advise is to start all over
rails new myApp
cd myApp
rails generate scaffold Post name:string title:string content:text
rake db:migrate
rails s
At point your browser to http://localhost:3000
Then you'll see the rails welcome page
If you point the browser to http://localhost:3000/posts you'll get to the post index page
And read this rails guide
update
Are you running rails generations from another user? It looks like you don't have read and write rights to the files from textmate.
Embarrassing lesson. The server was attached to a different directory. And apparently the symbol isn't read/write.. Not sure what it is though

How to list all REST URLs in Ruby on Rails commanline

I want to get list of all REST URLs in one of rails project. I think there is a command to get them.I am new to rails so no luck so far.
Thanks
Smith
rake routes should do the trick.
open command prompt
Navigate to project folder
run rake routes

Simple redirect from public to views in ror

I am looking for a simple way to redirect the public/index.html to the app/views/public/index.html.erb the site is already deployed and I'm sick of it not being the first thing when you go to the domain.
You should have public/index.html deleted and use rails routes instead.

Trying to learn RoR, but keep getting Page doesn't exist errors

I'm trying to learn RoR and I keep getting pesky page doesn't exist pages. I deleted the index.html file out of my public folder and created a root route in my routes file but I still am getting that error. I am running ubuntu 10.04 with mod_passenger and ruby enterprise edition.
just leave the mod_passenger until you find the error. Do like this:
open a shell
go to your Rails app directory
ruby script/server (Rails < 3).
It should start the server in your console. and browse the page you want. If you are getting an error it should display in the console.
check your database connection is OK in config/database.yml file
rake routes is the standard shell command to see all your routes. Check if url you're trying to access is in the list. If it's not, show us statement in routes.rb you use to generate this route and url you're trying to access.
Can you please paste the content of your routes.rb file?
Also, make sure you have a controller created for that page and it should contain the index action.
def index
end

Resources