蓋伊我有一些奇怪的事情在我的項目爲什麼我的MySQL數據庫可以在不更新閱讀或在軌道4,5插入數據?
現在我老Ruby on Rails項目開發中有一些注意事項後,我激活指令
bundle
bundle exec rake db:create
bundle exec rake db:migrate
rails s
應用程序首先問我安裝mysql2 0.3。 14,安裝完成後,我得到了錯誤
log writing faild. invalid byte sequence in US-ASCII
,我在每一個第一線解決它通過添加#encoding: utf-8
在項目模型
終於現在我可以打開我的項目以及但
我發現當我看到從我的DB數據試圖從我的MySQL數據庫沒有發生在我身上插入或更新任何數據時,這樣的工作!!!!!我認爲我的DB用戶只需要權限只從數據庫中讀取,但檢查了用戶權限後,我發現它需要的所有權限
這樣可以,爲什麼我去這個問題的任何一個給我解釋一下????
這是一個簡單的代碼插入到我的MySQL數據庫 視圖代碼
<%= form_for(@category) do |f| %>
<div class="field">
<%= f.label :title %><br>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :icon %><br>
<%= f.file_field :icon %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
控制器代碼
def create
#Just test to insert fixed data to my DB but also not insert any thing
@category =Category.new(:title => 'eeeee', :icon_file_name => 'xxx', :slug => 'sug')
#@category =Category.new(:title => params[:title], :icon_file_name => params[:icon], :slug => params[:slug])
#@category = Category.new(category_params)
respond_to do |format|
if @category.save
format.html { redirect_to @category, notice: 'Category was successfully created.' }
format.json { render action: 'show', status: :created, location: @category }
else
format.html { render action: 'new' }
format.json { render json: @category.errors, status: :unprocessable_entity }
end
end
end
注:我使用Windows 7
你能在更多的細節發生了什麼解釋。 db中沒有新記錄?你是否被重定向到顯示操作或停留在表單上?任何錯誤消息? – BroiSatse
沒有錯誤信息 這種情況讓我瘋狂 – Astm