What is wrong with my config/routes.rb file? - ruby-on-rails

I'm using the ruby 2.1.2p95 version, and I'm running into some problems following directions to this tutorial (http://tutorials.jumpstartlab.com/projects/blogger.html) on creating a blog.
I followed exactly what the tutorial said, up until the step "Setting up the router." Once I open config/router.rb, the first line in my document is "Rails.application.routes.draw do," not "Blogger::Application.routes.draw do."
The reason I'm asking is in the tutorial on Jump Start Lab, after I continued to the "Creating Template Step," I received a different error message from "Template missing...". I got "Unknown actions...", and eventually, I couldn't view the index page.
I also looked at another tutorial on Youtube (https://www.youtube.com/watch?v=-GQmC-8k09c), and I got the same problem, where the config/router.rb's first line remains the same.
Do you know why this is happening?
Am I supposed to manually change the first line from "Rails.application..." to "[Name of app]::Application.routes.draw do"?

I try with Rails 4.0.4, and it's Blogger::Application.routes.draw do but with rails 4.1.4 it's Rails.application.routes.draw do. I didn't see any news about new router api, so it should be same.
But if you wanna follow tutorial then you can make:
gem uninstall rails
and remove rails 4.1.* then install rails 4.0 with command
gem install rails -v 4.0.8

Related

pdf.js gem producing errors

I am a rails novice and trying to create my web portfolio in Cloud9. I wanted to display my resume.pdf in the user browser so I installed this gem gem 'pdfjs_rails' now my app doesn't even start in cloud 9. It show the following error messages in the terminal:
Please help me. How can i revert it back? thanks
Doesn't look like anything related to pdfjs (no point in that direction). Are you sure you've selected the right runner in Cloud9? See:
https://community.c9.io/t/error-when-running-ruby-project/11799/4
More in general: if you think an issue would be related to a gem, you can simply remove it from the Gemfile and run gem bundle to 'revert' to a previous state.

Rails 4.2 + Ember => unexpected identifier

I'm following Vic Ramon's tutorial. I tried to use the latest version of Rails and Ember-source and I get the following error when visiting home page:
After clicking on link next to error I get this:
How can I fix that?
I ran the following commands:
rails g ember:bootstrap -n App --javascript-engine coffee
rails g ember:install
I removed turbolinks. I also created home controller and an empty view for home#index. Root is set to home#index. Also created following view file:
// app/assets/javascripts/templates/application.js.emblem
h1 Hello World
outlet
Ember gems im using:
Using emblem-source 0.3.18
Using ember-data-source 1.0.0.beta.14.1
Using ember-rails 0.16.1
Using emblem-rails 0.2.2
This could be due to some version incompatibilities between your versions of ember-related gems, as there were quite substantial changes in recent versions of ember (e.g. introduction of HTMLBars, etc.)
Your best bet is to clone the original repo and then try to upgrade individual gems and check if it still works after each upgrade. This way you will be able to identify the troubling gem.
I have verified that the original repo code indeed works with the versions of gems in its current Gemfile.lock.
If you are starting a new Rails + Ember app, ember-cli-rails is probably the way to go, giving you the best of both worlds.
Emblem was the culprit. Replacing .emblem with .handlebars fixed the problem. I tried the tip from emblem-rails git page and icluded
gem "emblem-source", github: "machty/emblem.js"
but that didn't change anything.
I also followed this tutorial (alongside a few others) and I encountered several issues alongside the way ranging from handling templates to setting up the JSON API. I don't see your entire source code so I cannot pinpoint the exact problem. However, it seems that we have similar projects, so you can compare your code to my blog project source code and see what is causing these issues. Comparing to Ramon's tutorial, my blog has implemented everything until chapter 15.
https://github.com/Deovandski/Fakktion/tree/Ember-Rails
If you are a beginner like myself, then I recommend avoiding CoffeeScript and Emblem and sticking to Javascript as much as possible for the first months because you will find more resources and examples. Also, let me know if you need assistance in setting up the project as I used .gitignore to hide things like secrets.yml

Rails_Layout "Could Not Find Layout Generator"

I'm trying to use this command in Terminal: rails generate layout simple --force and when I do I get this error: Could not find generator layout. So I attempted to try to be more specific in my gemfile, and added the specific, newest version number to the file (gem 'rails_layout', ~> '1.0.5'), and still get the same error. I did a little searching and found this similar question: zurb_foundation layout generation in rails and the answer seems to say that Foundation now includes the layout generator in it's own gem? Or am I reading that wrong? Anyway, I did a gem uninstall rails_layout and then tried the original command again. Still, no go. Same, original error of not being able to find the layout generator. I'm on Rails 4.0.2 and Ruby 2.0.0 Does anyone have any suggestions? Thank you!
You're reading the book Learn Ruby on Rails. But you're reading an out-of-date version of the book. The latest version of the book is v1.19. You'll see the correct syntax for use of the rails_layout gem is:
$ rails generate layout:install simple --force
If you check the README for the rails_layout gem you'll see the correct commands:
https://github.com/RailsApps/rails_layout
The rails_layout gem gives you an easy way to set up application layout, flash messages, and navigation partials. If you don't use the generator command, you can copy the example code from the book to get what you need (the generator command gives you a shortcut). Later in the book, you'll learn how to install Foundation and set up the application layout, flash messages, and navigation partials for Foundation. You could follow the instructions on the Foundation website but again, the rails_layout gem gives you a shortcut.
In summary: Make sure you have the newest version of the book.

Run rails code online

Can any body give me a link to run rails code online??
I have tried codepad.org and tryruby.org they are running the ruby code fine
When I use Time.now it gives me correct result but when I try to run like below it give me errors:
time_ago_in_words(Time.now - 15.hours)
Thanks
The hours function is specific to Rails, which is a Ruby library. Rails is not loaded in CodePad. You'll have to install Rails on your computer to access those functions. Consult a guide for instructions. 1
Rails for Zombies provides an interpreter, but it's geared toward their lessons.

Cane with Rails

I just discovered the Cane gem but it doesn't work with Rails, there is a way to make it work with Rails?
Update
I'm using rails 3.2.1 and It doesn't produce any error message
I'm the author of this gem.
How do you mean "doesn't work"? It's possible you just write good code :) The default options aren't too strict. Can you please post the output of:
cane --style-glob '**/*.rb' --style-measure 1
This should error on every line in the project, to verify whether cane is "working". And also
find . app
When run from within your rails directory.

Resources