01.08 全棧營學習紀錄 09

錯誤:


解法:xxx_add_is_hidden_to_job.rb
多了一個end
rails d migration,
rails g migration,
把xxx_add_is_hidden_to_job.rb 改成這確的
rake db:migrate

Extracted source (around line #572):
570
571
572
573
574
575

  # Raises <tt>ActiveRecord::PendingMigrationError</tt> error if any migrations are pending.
  def check_pending!(connection = Base.connection)
    raise ActiveRecord::PendingMigrationError if ActiveRecord::Migrator.needs_migration?(connection)
  end

  def load_schema_if_pending!

錯誤:薪資上限

wange_upper_bound
wage_upper_bound

解法:1.全部改成wange or

  1. 刪掉migration 重做 rails d migration add_more_detail_to_job.rb

錯誤:

Showing /Users/ericahsu/job-listing-3/job-listing/app/views/jobs/index.html.erb where line #2 raised:

undefined local variable or method `new_job_path' for #<#<Class:0x007fd0bcf55390>:0x007fd0bcf47420>
Did you mean?  new_session_path
Extracted source (around line #2):              
<div class="pull-right">
  <%= link_to("Add a job", new_job_path, :class => "btn btn-default") %>
</div>

<table class="table table-boldered">
  <% @jobs.each do |job| %>

解法:routes.rb 要有兩行resources :jobs

Rails.application.routes.draw do
  devise_for :users
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  namespace :admin do
    resources :jobs
  end
  resources :jobs
  root 'jobs#index'

end

錯誤:在console 裡面新增Jobs 失敗,遇到“you have encounter a bug"
解法:把Gemfile 裡面的Spring 那兩行關起來

錯誤:不小心打錯目錄名稱,create 了用不到的目錄怎麼辦?
解法:rmdir xxx/xxx/xxx

錯誤
navbar.html.erb 排版跑掉: 前後的li要放

<li>
                    <% if !current_user %>
                      <li><%= link_to("註冊", new_user_registration_path) %></li>
                      <li><%= link_to("登入", new_user_session_path) %></li>
                    <% else %>
                        <li class="dropdown">
                          <a href="#" class=dropdown-toggle" data_toggle="dropdown">
                            HI, <%= current_user.email %>
                            <b class="caret"></b>
                          </a>
                          <ul class="dropdown-menu">
                            <li> <%= link_to("登出", destroy_user_session_path, method: :delete) %> </li>
                          </ul>
                        </li>
                        <% end %>
            </ul>
          </li>

錯誤:
admin 之後的作業都跟前面作業代碼有關,前面自己做得無法相連要全部重來
重來的話是用git 回到最初的branch?

回到根目錄,mkdir 新目錄,cd 新目錄。git clone git@github.com:quanzhanying/job-listing.git

接下來按照教材做

第三次Pull request

做錯了要回前一個分支,應該怎麼做?

git branch  (看現有分支 
git add .
git commit -m (現在分支要先儲存才能切換
git checkout step2 (剛剛在git branch看到的
git branch -D step3

加入simpleform 的時候失敗

rails g controller groups,不是group

看不懂教材裡面的登入登出要怎樣才算做好,以為安裝好devise 就可以登入了,但安裝好後還需要修改

_navbar.html.erb 

Comments

comments powered by Disqus