w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Ruby on Rails Tutorial by Michael Hartl Chapter 2 exercise (demo_app): app works on Windows 8 localhost, but doesn't work on Heroku
The error is here: 2013-07-18T23:47:29.239184+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 40177 -e $RAILS_ENV` 2013-07-18T23:47:30.141486+00:00 app[web.1]: bash: bin/rails: No such file or directory Try adding a Procfile to your application that has this: web: bundle exec rails server -p $PORT

Categories : Ruby On Rails

Possible bug in Rails 4 Tutorial, section 9.6, exercise 1
I just wanted to confirm that I'm seeing the same behavior when the "forbidden attributes" test is nested within the "edit" test block. My notes indicate that it was mentioned in Chapter 9 that when ever you're doing a direct POST, PATCH, GET or DELETE request, as opposed to using visit, the no_capybara: true option needs to be given to the sign_in method to ensure the user is signed in. However, in this case if you use the no_capybara: true option with sign_in the other tests in the "edit" block will fail due to some Capybara issues. As mentioned by the OP, if the option is omitted, then the "forbidden attributes" tests pass regardless of the presence, or lack thereof, of :admin in the user_params method within the Users controller.

Categories : Misc

Ruby on Rails Tutorial Exercise 3.5
It's unsafe to run bundle update because this command update all your gems , and new versions of gems could break your application, this is what was happens when you are doing bundle update, i suggest for you this article to understand more about bundle update command. I think you use Git ? if yes what about return to previous commit you are already doing ? git reset --hard commit_name so an example of this is : git reset --hard f460cb...... commit name can be found using command: git log another solution i think more convenient is to restore your old Gemfile.lock (Gemfile.lock is the file which contains your old gems versions and dependencies of each gem). you can find how to do this here How do you rollback to a previous Gemfile.Lock

Categories : Ruby On Rails

Rails Tutorial Ch. 9 Exercise 6: Expected response to be a , but was <200>
Were you able to get your tests to pass? In case you weren't, I had the same problem as you today, and was able to get the tests to pass by making two changes to the tests - passing a user hash when POSTing, and using the no_capybara option on the sign_in method, since get and post are not capybara methods and I think RSpec doesn't behave as we might expect if we switch from capybara to non-capybara methods within the same test. describe "for signed-in users" do let(:user) { FactoryGirl.create(:user) } before { sign_in user, no_capybara: true } describe "using a 'new' action" do before { get new_user_path } specify { response.should redirect_to(root_path) } end describe "using a 'create' action" do before do @user_new = {name: "Example User",

Categories : Ruby On Rails

Unexpected Capybara Warnings - Rails Tutorial Chapter 9 Exercise 9
I think in second case rails couldn't able to find admin? method since its not present. Thats why you are getting this error NoMethodError: undefined method `admin?' for nil:NilClass did you ran these codes $ rails generate migration add_admin_to_users admin:boolean $ bundle exec rake db:migrate $ bundle exec rake test:prepare As per your error, i think rails is looking for a method instead of just checking boolean value for admin.

Categories : Ruby On Rails

Michael Hartl's Ruby on Rails Tutorial: Chapter 9, Exercise 3
I might be missing something but I can't see which tests you have added for this exercise. I have just completed this and now the first AuthenticationPages tests look like this. authentication_pages_spec.rb describe "sigin page" do before { visit signin_path } it { should have_content('Sign in') } it { should have_title('Sign in') } it { should_not have_link('Users') } it { should_not have_link('Profile') } it { should_not have_link('Settings') } it { should_not have_link('Sign out', href: signout_path) } it { should have_link('Sign in', href: signin_path) } end

Categories : Ruby On Rails

Hartl RoR Tutorial Chapter 5 Exercise 1: Failing test: it_should_behave_like and should_not have_title
Try updating Capybara to the version 2.1.0 in your Gemfile. have_title is one of the new selectors. Check out this answer for more information

Categories : Ruby On Rails

Forking Rails Tutorial sample_app for Rails 4
You need to fork the repo, get it in your personal GitHub repository, and then clone the version that is in your personal repo. Here is a GitHub article on forking and cloning: https://help.github.com/articles/fork-a-repo Here are the steps at a high level: Go to Hartl's repo and click fork. This will copy the project in your GitHub account. Clone the repo from your personal account: $ git clone git@github.com:your_github_usernamesample_app_rails_4.git

Categories : Github

Project euler exercise 10 on Java. isPrime method doesn't work in the loop
I don't really think that there is anything to do with the loop... However, there is a logic flaw in the code... public static boolean isPrime(int num) { long i; for (i=2; i <= Math.sqrt(num) ; i++){ long n = num%i; if (n == 0){ return false;//found a divisor : not prime } } //went through all the way to sqrt(num), and found no divisor: prime! return true; } We can stop whenever the first divisor is found, there is no need to find all of them -- that is another excercise... Also, logically, if one wanted to use the boolean variable this way, it would have been initialised with true, and put to false, and kept at that, when a divisor is found...

Categories : Java

Rails Tutorial 8.25
Stepping away and coming back at another time works best. The problem I had was in the views/sessions/new.html.erb which seems like the only file I wasn't looking at at the time. I accidentally had the password label and password_field using symbol :Password instead of :password.

Categories : Misc

Rails Tutorial Sample App 6.26
You're probably missing the bcrypt-ruby gem. You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use has_secure_password: gem 'bcrypt-ruby', '~> 3.0.0'

Categories : Misc

Ruby Rails Tutorial 8.25
In SessionsHelper#current_user you have line: @current_user ||= User.find_by_remember_token(:cookies[:remember_token]) Since cookies are the method that returns cookies Hash (HashWithIndifferentAccess, to be precise), it should be: @current_user ||= User.find_by_remember_token(cookies[:remember_token])

Categories : Ruby On Rails

Cannot get tutorial app to work - Android
As eclipse user I am not familiar with android studio, but according to your screenshot it actually seems to be caused by the deprecated method you're using. I guess you can't "just" replace te name of the method you're using, because create will most likely work a little different. But yeah, if you work it out to do the same in the end you should be fine. EDIT: Oh, and what I just saw: Did it already work before? Because if not, look at the error about the missing Java compiler. Look up, how to add this to your HOME Path variable!

Categories : Java

TypeError in Getting Started with Rails tutorial
You are using rails version 3.2.xx, on rails version 3.2.xx not include strong_parameters gem Note that def post_params is private. This new approach prevents an attacker from setting the model's attributes by manipulating the hash passed to the model. For more information, refer to this blog post about Strong Parameters. Add gem "strong_parameters" to your Gemfile, then run bundle install include ActiveModel::ForbiddenAttributesProtection on your model or create config/initializers/strong_parameters.rb and put this : ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)) config.active_record.whitelist_attributes = false in config/application.rb https://github.com/rails/strong_parameters

Categories : Ruby On Rails

Rails Tutorial Chapter 2, section 2.3.3
The problem is that your Micropost model has no column named user_id. Look at your console output from Micropost.all - there's no attribute in the returned instance named user_id. Maybe you forgot to run a migration? Maybe you rolled back a migration? Maybe you missed a step completely? When you generated the scaffold, maybe you forgot the part about the user. Playing around with the app (adding, deleting, editing) won't cause the issue you have. When you retrieve the first user again, and ask to see their miscroposts, if everything was set up properly, you'd get back something - at least an empty relation.

Categories : Ruby On Rails

Ruby on Rails Tutorial stuck
Move your config inside the class, like so: module SampleApp class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_local

Categories : Ruby On Rails

Rails 4- Associations -Tutorial Movielist
After debugging including Chicagogrrl's !flag I investigated the params.permits in the movies_Controller again and figured I would have to add the method types to the list of excepted. I could not find detailed info on syntax for this but trial and error paid off. app/controllers/movies_controllers.rb (excerpt) ...... # Never trust parameters from the scary internet, only allow the white list through. def movie_params params.require(:movie).permit(:title,:description, :rating, :role, :deleted_roles=>[], :new_role=> ['person_id', 'name']) end ...... The delete_roles=>[] takes the array params and process to delete_roles method in movies.rb the new_role=>['person_id', 'name'] takes the new_role individual params. I Hope this saves somebody else

Categories : Ruby On Rails

i'm trying to work with sqlite, having prob regarding this tutorial
Just place it in your activity somewhere, but I really don't like that tutorial. You don't want to create a database multiple times so you're going to have to check if it is created already. It's extending SQLiteOpenHelper but with an empty implementation for the actual useful parts. If you're doing an actual extension of SQLiteOpenHelper - all you have to do is the first line (DataBaseHelper myDbHelper = new DataBaseHelper(this);) in your activities onCreate(). Check this out.

Categories : Android

Ch. 10.3.3 Ruby on Rails Tutorial Undefined Method 'any?'
@feed_items is nil, and you're trying to call any? on it. Nil doesn't have that method. Your controller is "home", but your view is "index". It may be that your controller action isn't being run, and that @feed_items isn't being populated as a result. Try renaming home to index and see if that fixes it.

Categories : Ruby On Rails

ruby on rails tutorial errors chapter 9
Now is the time on Stack Overflow when I oversimplify. (Google 'ruby block' to read a lot more on this.) A block in Ruby is a bunch of code that gets passed to a method like an argument. For example, [1,2,3].each{|n| puts n * n } each is the method (called on the array [1,2,3]), and everything in the brackets is the block. The way the method each works is, it takes every element in the enumerable it`s called on ([1,2,3]) and yields one element at a time to the code block: |the first element is 1| puts 1 * 1 |next is 2| puts 2 * 2 |etc| puts 3 * 3 A block can also be written between do...end. The Ruby way is to use brackets if you can fit the block on one line, and do...end otherwise - which is just how you have it in your specs. Everywhere you have a do and a matching end in your sp

Categories : Ruby On Rails

Security with redactor.js - is there such tutorial for ruby/rails
Security on this level (as mentioned in article) is built into Rails so deeply you don't even have to think about it. You can read more in Rails Guides Just to mention one of the features highlighted in the article - referrer checking (it makes me laugh someone want's to secure app in such a way) In Rails, to secure possibly destructible requests (POST, GET and DELETE) we use authenticity token. It is a one use string that get's saved in session when a form is generated and allows to verify that user actually displayed the form before performing a request. (I know a good answer should be more elaborate but I don't think it makes sense to copypaste Guides here...)

Categories : Ruby On Rails

PyOpenGL - A tutorial about shaders that doesn't work
It is failing because you don't have GLUT installed. GLUT is the GL Utility Toolkit, a very widely used simple framework for creating OpenGL programs that runs on MS Windows, Macs, Linux, SGI, ... All the functions and constants have a glut or GLUT_ prefix, and glutInitDisplayMode is the usually the first function that gets called. [ REMOVE INSTALLATION NOTES ] OK, you've done the install and it still doesn't work. That means that while you have GLUT installed, the Python program can't load the GLUT DLL. Dynamic linking, oh joy. Find where glut32.dll got installed. A quick and dirty solution for a single program is to copy the glut DLL into the same directory as the program itself. GLUT is 32 bit (AFAIK, unless you built it yourself) and this can be tricky if you have a 64 bit versio

Categories : Python

Rails Tutorial add test for user signing out but fails
The page variable you are accessing in your example is only available with use of Capybara methods such as visit and click. By directly issuing the HTTP delete operation, you are bypassing Capybara and the setting of the page variable. You can access the response body as response.body using your example, but note that the tutorial shows a test of sign-out at http://ruby.railstutorial.org/book/ruby-on-rails-tutorial#code-signout_test using a different request spec and Capybara's click method.

Categories : Ruby On Rails

Rails Tutorial 3 chapter 7.1.3 rspec failing tests
Remove the quotation marks in line 18 and 19. That should pass your tests. Like this: describe "profile page" do let(:user) { FactoryGirl.create(:user) } before { visit user_path(user) } it { should have_selector('h1', text: user.name) } it { should have_selector('title', text: user.name) } end Also look for your routes.rb. In the rails tutorial it is well match '/help', to: 'static_pages#help' match '/about', to: 'static_pages#about' match '/contact', to: 'static_pages#contact' unless you have create the static pages views with the name pages. Then forget my routes.rb

Categories : Ruby On Rails

Rails Tutorial by Michael Hartl no stylesheet in heroku
In production, all you css is compressed, its Fingerprinting : <link href="/assets/application-7270767b2a9e9fff880aa5de378ca791.css" media="all" rel="stylesheet" type="text/css" /> Fingerprinting is a technique that makes the name of a file dependent on the contents of the file. When the file contents change, the filename is also changed. For content that is static or infrequently changed, this provides an easy way to tell whether two versions of a file are identical, even across different servers or deployment dates. Fingerprinting is enabled by default for production and disabled for all other environments Read more about Fingerpriting

Categories : Ruby On Rails

'Getting Started with Rails' tutorial section 5.7 - route syntax
I guess that the doc needs some updating, since before it tells you to add resources :posts to your routes.rb configuration file, which should automatically add all 7 rest routes for you. The guide tells you that the show action is absent in your controller. I think that the whole sentence should be reworded :)

Categories : Ruby On Rails

rspec loaderrror issue during Chapter 3 of Rails Tutorial
You need to update your gemfile. gem 'selenium-webdriver', '2.0.0' to gem 'selenium-webdriver', '~> 2.35.1' The the root of your problem.

Categories : Ruby On Rails

Rails Tutorial 5.3.0 TDD Error: "undefined method 'visit'"
You have actually misspelled the word visit: before { vist root_path } And for the test to pass, you need to change the path of the About and Help tests to their respective paths. For example, you are testing the Help page but instead of visiting the help_path, you are visiting the root_path describe "Help page" do before { visit root_path } Same goes for the About page.

Categories : Ruby On Rails

Rails 4 link_to Destroy not working in Getting Started tutorial
Started GET "/posts/4" for 127.0.0.1 at 2013-08-09 13:45:20 -0600 This is the problem. The delete link is using GET http verb even though you used method: delete in your link. Check out the following SO thread

Categories : Ruby On Rails

"find_by" error while following Michel Hartl's tutorial, even with Rails 4
See learning from a material is good but i would recommend you not to copy the entire thing because it greatly reduces the amount of learning. Said that find_by is no direct method for models in rails for all versions if you want to find by id you can just use find(id_value) and if you want to find based on a particular column then you should use find_by_columnname(column_value) that will work. If you need more clarification or the error persists then pls ask.

Categories : Ruby On Rails

Rails tutorial 3.6, 'bin' is not recognized as an internal or external command
Just thought I'd reiterate the author's warning about this section: "This section should only be attempted by fairly advanced users and can be skipped without loss of continuity. Among other things, this material is likely to go out of date faster than the rest of the tutorial, so you shouldn’t expect everything on your system to match the examples exactly, and you may have to Google around to get everything to work." As a side note... I originally tried to use ruby on rails on a windows machine but I found that much of the support community used apple or linux boxes. I have been much happier since I started dual-booting into Ubuntu. The transition was easier than I expected and I have had fewer issues with gems.

Categories : Ruby On Rails

Ruby Rails Hartl Tutorial Ch. 8.2.6 Test Failures
I guess the problem is here: <li><%= link_to "Users", '#' %></li> <li><%= link_to "Settings", '#' %></li> tests clearly says expected link "Settings" to return something expected link "Users" to return something but both your links paths are nil or #, you should set the path to links: <%= link_to "Settings", edit_user_path(current_user) %> <%= link_to "Users", users_path %> that's just an opinion of mine, I am not that good at tests.

Categories : Ruby On Rails

ArgumentError in Users#index for Hartl Rails Tutorial
Congratulations on getting to Chap. 9! I'm bored to tears in Chap. 6 Line 2 is this: <%= gravatar_for user, size: 52 %> ...which is equivalent to: <%= gravator_for(user, {size: 52}) %> That's two arguments.

Categories : Ruby On Rails

rails tutorial: cookie doesn't match remember token
first of all, User_find_by() isn't a method. it's User.find() or User.find_by_columnName() where columnname is the column in your database that you want to search. also, you have to make sure your User model is defined correctly. i'm assuming you followed all the instructions til that point so you have the new_remember_token and encrypt methods and you have the create_remember_token private method? also make sure you have the before_create filter.

Categories : Ruby On Rails

Ruby on Rails Tutorial Confused about how Params hash works
It's based on rails routing model. If you used resources :user in config/routes.db it will create the following route (you can view it by running rake routes) : DELETE users/:id the symbol :id means that whatever you add after users/ while calling url will be set in params as :id. (in the case, for the DELETE HTTP verb)

Categories : Ruby On Rails

Understanding RSPEC Users tests in Ruby on Rails Tutorial
About your first point, the validation for uniqueness indeed occurs when you call save. However, you can also invoke all the validations by calling valid? - which is what be_valid does. So it doesn't actually need to save the @user model for this test to work. About your second point, RSpec absolutely writes to the database. However, it runs each test within a transaction scope (by default). At the end of each test, instead of committing the transaction, it rolls it back. This leaves the database in the same state it was before the test started, effectively allowing each test to be isolated from the others while making use of the database just as your code would do in production (almost). Regarding your point about the file modification time, SQLite doesn't necessarily write out the

Categories : Ruby On Rails

Ruby on Rails Tutorial Chapter 5 Failure/Error it {should have_selector
The problem is in your spec file -- describe "StaticPages" do subject { page } describe "Home page" do before { visit root_path } it { should have_selector('h1', text: 'Sample App')} it { should have_selector('title', text: full_title(''))} it { should_not have_selector 'title', text: '| Home'} end end You are ending the rspec context too soon -- move the last 'end' to the bottom of your spec, and your tests should all pass. cheers!

Categories : Ruby On Rails

Michael Hartl's Rails Tutorial Chapter 10 destroy method
I can help you with DELETE method, it is pretty easy in fact: most browser don't support methods PATCH, PUT & DELETE so Rails cheat in a way by passing through the parameter "_method" and converting it internally. That is why you see it as a GET, which it is until it hits Rails internals. You can read more here: http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark HTH

Categories : Ruby On Rails

rails tutorial ch 2 error noMethodError: undefined method 'micropost'
your User model look like class User < ActiveRecord::Base attr_accessible :email, :name end No association is defined. Make it: class User < ActiveRecord::Base attr_accessible :email, :name has_many: :microposts end You mentioned it in your post , but it does not reflect your code

Categories : Ruby On Rails

Trouble in Chapter 8 of Michael Hartl's Rails Tutorial - CSS Expects
Inspect from your web page source code: <div class="alert alert -error">Invalid email/password combination</div> The target div has class alert and -error. However, in your testcase, you are expecting a div with class alert and alert-error it { should have_selector('div.alert.alert-error', text: 'Invalid') } I think you have typed an extra space between alert and -error, it should be alert-error (without space). You should check your layout view, because sessions/new.html.erb you pasted doesn't include the source that generates this line of HTML. UPDATE: As commented by Dylan Markow, you might have typed an extra space in <div class="alert alert-<%= key %>">.

Categories : CSS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.