Trouble with rails tutorial -


i working through rails tutorial, still new to. app designed show status posts comparable facebook. @ point must have missed something, , can't figure out where. status content no longer displaying me.

here index:

<div class='page-header'>     <h1>all of statuses</h1> </div>  <%= link_to "post new status", new_status_path, class: 'btn btn-success' %>  <% @statuses.each |status| %> <div class='status'>     <strong>name</strong>         <p><%= status.content %></p>     <div class='meta'>         <%= link_to time_ago_in_words(status.created_at) + " ago", status %>         <span class='admin'>                 | <%= link_to "edit", edit_status_path(status) %> |             <%= link_to "delete", status, method: :delete, data: {confirm: 'are sure?'} %>         </span>     </div> </div> <% end %> 

here form:

<%= simple_form_for(@status, html: {class: 'form-horizontal'}) |f| %>   <% if @status.errors.any? %>     <div id="error_explanation">       <h2><%= pluralize(@status.errors.count, "error") %> prohibited status being saved:</h2>        <ul>       <% @status.errors.full_messages.each |message| %>         <li><%= message %></li>       <% end %>       </ul>     </div>   <% end %>    <%= f.input :content %>   <div class="form-actions">      <%= f.button :submit %>   </div> <% end %> 

status.content not displaying @ , can't figure out why. please let me know if failed include file, didn't want include ton of unnecessary code.

thanks!

controller:

class statusescontroller < applicationcontroller   before_action :set_status, only: [:show, :edit, :update, :destroy]    # /statuses   # /statuses.json   def index     @statuses = status.all   end    # /statuses/1   # /statuses/1.json   def show   end    # /statuses/new   def new     @status = status.new   end    # /statuses/1/edit   def edit   end    # post /statuses   # post /statuses.json   def create     @status = status.new(status_params)      respond_to |format|       if @status.save         format.html { redirect_to @status, notice: 'status created.' }         format.json { render :show, status: :created, location: @status }       else         format.html { render :new }         format.json { render json: @status.errors, status: :unprocessable_entity }       end     end   end    # patch/put /statuses/1   # patch/put /statuses/1.json   def update     respond_to |format|       if @status.update(status_params)         format.html { redirect_to @status, notice: 'status updated.' }         format.json { render :show, status: :ok, location: @status }       else         format.html { render :edit }         format.json { render json: @status.errors, status: :unprocessable_entity }       end     end   end    # delete /statuses/1   # delete /statuses/1.json   def destroy     @status.destroy     respond_to |format|       format.html { redirect_to statuses_url, notice: 'status destroyed.' }       format.json { head :no_content }     end   end    private     # use callbacks share common setup or constraints between actions.     def set_status       @status = status.find(params[:id])     end      # never trust parameters scary internet, allow white list through.     def status_params       params.require(:status).permit(:name, :content)     end end 

log terminal (i think it?)

started post "/statuses" 127.0.0.1 @ 2014-06-27 11:47:14 -0700 processing statusescontroller#create html   parameters: {"utf8"=>"✓",     "authenticity_token"=>"0e4j7grzxbusmcf+hoe69gjzjpnprt/24p5w4t9/cca=", "status"=>    {"content"=>"new status test"}, "commit"=>"create status"} warning: can't mass-assign protected attributes status: content     app/controllers/statuses_controller.rb:27:in `create'    (0.1ms)  begin transaction   sql (0.7ms)  insert "statuses" ("created_at", "updated_at") values (?, ?)      [["created_at", "2014-06-27 18:47:14.783419"], ["updated_at", "2014-06-27    18:47:14.783419"]]    (1.0ms)  commit transaction redirected http://0.0.0.0:3000/statuses/9 completed 302 found in 11ms (activerecord: 1.8ms) 

status model:

class status < activerecord::base end 

you should adding attr_accessible :content status model in order mass assign attributes.

class status < activerecord::base  attr_accessible :content  end 

if need display name attribute along content,then change attr_accessible :name, :content.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -