but i am having a problem listing the accounts in the new user view
Users Controller
Expand|Select|Wrap|Line Numbers
- class UsersController < ApplicationController
- before_filter :authenticate_user!
- def index
- @user = User.all
- end
- def show
- @user = User.find(params[:id])
- end
- def new
- @user = User.new
- @account = Account.all # i think this line should give me all the accounts
- end
- def create
- @user = User.new(params[:account])
- if @user.save
- flash[:success] = "User Created"
- redirect_to @user
- else
- render 'new'
- end
- end
- def edit
- @user = User.find(params[:id])
- end
- def update
- @user = User.find(params[:id])
- if @user.update_attributes(params[:user])
- flash[:success] = "User Updated"
- redirect_to @account
- else
- render 'edit'
- end
- end
- def destroy
- User.find(params[:id]).destroy
- flash[:success] = "User Destroyed."
- redirect_to user_path
- end
- end
View
Expand|Select|Wrap|Line Numbers
- <%= provide(:title, 'New User') %>
- <!-- Main content -->
- <section role="main" id="main">
- <div class="with-padding">
- <%= form_for(@user) do |f| %>
- <table class="simple-table responsive-table">
- <tbody>
- <tr>
- <td scope="row">
- <%= f.label :email %>
- </td>
- <td><%= f.email_field :email %></td>
- </tr>
- <tr>
- <td scope="row">
- <%= f.label :username %>
- </td>
- <td><%= f.text_field :username %></td>
- </tr>
- <tr>
- <td scope="row">
- <%= f.label :password %>
- </td>
- <td><%= f.password_field :password %></td>
- </tr>
- <tr>
- <td scope="row">
- <%= f.label :password_confirmation %>
- </td>
- <td><%= f.password_field :password_confirmation %></td>
- </tr>
- <tr>
- <td scope="row">
- <%= f.label :first_name %>
- </td>
- <td><%= f.text_field :first_name %></td>
- </tr>
- <tr>
- <td scope="row">
- <%= f.label :last_name %>
- </td>
- <td><%= f.text_field :last_name %></td>
- </tr>
- <tr>
- <td scope="row">
- Account
- </td>
- <td>
- This needs to be a Selct Box
- <% @account.each |a| do %>
- a.name
- <% end %>
- </td>
- </tr>
- <tr>
- <tr>
- <td colspan=2><%= f.submit "Create User" , :class => "button" %> <%= link_to "Cansel", users_path, :class => "button" %></td>
- </tr>
- </tbody>
- </table>
- <% end %>
- </div>
- </section>
- <!-- End main content -->
The Error that i am having
SyntaxError in Users#new
syntax error, unexpected keyword_do_block
'); @account.each |a| do
^
/Users/moiseszaragoza/Sites/sample/app/views/users/new.html.erb:66: syntax error, unexpected keyword_ensure, expecting $end