ruby on rails - Print to console when method is called? -


i want print message browser console or page can see when each method called. nothing being printed , haven't found working solution. tried using flash messages didn't work well. i'm learning rails want see being called , when. example if create called want see message "create called!". have tried this:

    class postscontroller < applicationcontroller    # index, show, new, , edit pages have views   # create, update, , destroy kind of work , redirect   # instance variables visible in our view files   def index     @posts = post.all   end    def show     # find post , find id passed url     @post = post.find(params[:id])     flash[:success] = "show called in flash"     puts "show method called!"    end    def new     @post = post.new   end    def create     @post = post.new(params[:post])     if @post.save       redirect_to(posts_path, :notice => "your post saved!")      else       render "new"     end   end    def edit     puts "<p>edit method called!</p>"      @post = post.find(params[:id])   end    def update         puts "update method called!"      @post = post.find(params[:id])      if @post.update_attributes(params[:post])       redirect_to posts_path, :notice => "your post has been saved."     else       render "edit"     end   end    def destroy      puts "destroy method called!"       @post = post.find(params[:id])      @post.destroy       redirect_to(posts_path, :notice => "post deleted")   end   end 

use logger , tail log/development.log

logger.debug "method called" 

debug level logging logged in development environment. use info if want log in production


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -