RailsCasts Pro episodes are now free!

Learn more or hide this

0ptimus's Profile

GitHub User: 0ptimus

Comments by

Avatar

Hi guys, I have an app listing a bunch of inventory items and on my views I am showing columns with item.created_at and item.updated_at. After following this tutorial I have all of my columns sorting fine with the "arrows", except that I can't get the item.created_at and item.updated_at columns to sort. Any tips?

Thanks for any help!!!

Avatar

Troy, yeah, it's just an updatable list of printers. Not doing it in Active Directory. Hopefully someone can help with my issues :)!

Avatar

Thanks for all of the awesome tutorials Ryan!!! I'm a total Rails/coding newbie and I managed to build a directory of printers for my IT dept with your help :). Now I followed this tutorial to try and get emails sent via a Gmail account to a list address (newprinter@domain.org) whenever a new printer is added to the directory. However, I'm stumped as to how to get this working with my rails app and I hope you or someone else can help. Please be gentle with me :). My app is a little different from your example code as I don't require a user registration, it's just a simple directory listing printers (make, model, IP address, IP address, etc.), and people can add/edit/delete printers from the "directory". I am including code from my app which I think is relevant below, although I could be wrong :). There's probably something horribly obvious to you or others which I am not seeing or able to figure out. I'd appreciate any help in advice on getting this working. Or if I should be going a different route to send the emails, please let me know.

TIA,
Mark

Sample from my setup_mail.rb

ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "mail.gmail.com",
:user_name => "myitdept@gmail.com",
:password => "secret",
:authentication => "plain",
:enable_starttls_auto => true
}

ActionMailer::Base.default_url_options[:host] = "localhost:80"
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
~

Sample from my notifier.rb

class Notifier < ActionMailer::Base
default :from => "myitdept@gmail.com"

def newprinter_notification(list)
@list = "newprinter@domain.org"
mail(:to => @list, :subject => "New Printer Added to Directory")
end

end
~

Sample from my printers_controller.rb

def create
@printer = Printer.new(params[:printer])

respond_to do |format|
  if @printer.save
    Notifier.newprinter_notification(@list).deliver
    format.html { redirect_to @printer, notice: 'Printer was successfully created.' }
    format.json { render json: @printer, status: :created, location: @printer }
  else
    format.html { render action: "new" }
    format.json { render json: @printer.errors, status: :unprocessable_entity }
  end
end

end
~