1

(0 replies, posted in Ruby on Rails)

I'm working on a new project that uses ActionMailer but test emails are not showing up in my mailbox although my developer log files shows a copy of it. I've tried :smtp through my hosting company and get a timeout error. When I try :sendmail, it says that they email is sent but it never arrives.

I've tried the following configuration in my environment.rb file for sendmail.

  config.action_mailer.delivery_method = :sendmail
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_charset = "utf-8"

I setup an initializer file for smtp (which I also tried in environment.rb) like the following:

ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
    :address => "smtp.mydomain.com",
    :port => 25,
    :domain => "mail.mydomain.com",
    :user_name => "username",
    :password => "password",
    :authentication => :login
    }

I also tried this in my initializer file:

ActionMailer::Base.delivery_method = :sendmail 
ActionMailer::Base.perform_deliveries = true 
ActionMailer::Base.raise_delivery_errors = true 
ActionMailer::Base.default_charset = "utf-8"

Any guidance would be appreciated.

I'm running on a Mac with 10.4.11.

2

(12 replies, posted in Ruby on Rails)

I'm posting this for anyone else who may have run into this problem. I discovered that my MySQL upgrade change location and name of my MySQL socket. I found the following code, which fixed the db connection. Now I have to figure out how to restore my MySQL privileges.

  adapter: mysql
  database: db_name
  username: root
  password:
  host: localhost
  socket: <%=
        ['/usr/local/var/run/mysql/mysqld.sock', # darwinports
         '/usr/local/var/run/mysqld/mysqld.sock', # darwinports, again
         '/var/run/mysqld/mysqld.sock',           # ubuntu/debian
         '/tmp/mysql-vcw.sock'].select { |f| File.exist? f }.first %>


I hope that helps someone else.

3

(12 replies, posted in Ruby on Rails)

I've updated all of my code and removed anything that is no longer supported, deprecated, before updating my RoR setup. After a little googlin',  I found a fix for the rake error message:

$ gem install rake

1 down and 1 to go.


I don't get the mysql prompt either. I've tried "mysql" and "mysqladmin", with no positive results. It tells me that it is an unrecognized command. My bash_login looks like:

alias mysql="/usr/local/mysql/bin/mysql"
alias mysqladmin="/usr/local/mysql/bin/mysqladmin"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"

It doesn't appear that mysql is showing anywhere in my load paths. If I do the following, I can get mysql to respond.

$cd /usr/local/mysql/bin
$./mysqladmin

This is fine for testing but doesn't work with RoR. By the way, the Preference Pane for MySQL can start and stop the db server with no errors.

UPDATE
After more googlin', I discover another system file used by Terminal called .bash_profile. After a little playing around, I discovered that Terminal was using it instead of .bash_login, which is what I used when I originally configured my system. I still can't get MySQL to respond to a command yet.

4

(12 replies, posted in Ruby on Rails)

One more thing I discover migrating to (Rails 2.2.2, Gems 1.3.1) was that I had to replace boot.rb in my old app with the boot.rb from a new test app in order to work. Still no MySQL contact. I don't know if anyone else had this experience or not.

5

(12 replies, posted in Ruby on Rails)

I've installed Ruby 1.8.6 and got following error. I went back to 1.8.4 and get the same message now.

localhost:~/Desktop/testapp aaronhyde$ script/server
=> Booting lighttpd (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)
/usr/local/bin/rake:17: undefined method `require_gem' for main:Object (NoMethodError)


Here is what is in rake. If you have any ideas, please let me know.

1. #!/usr/bin/env ruby
2. #
3. # This file was generated by RubyGems.
4. #
5. # The application 'rake' is installed as part of a gem, and
6. # this file is here to facilitate running it.
7. #
8.
9. require 'rubygems'
10. version = "> 0"
11. if ARGV.size > 0 && ARGV[0][0]==95 && ARGV[0][-1]==95
12.  if Gem::Version.correct?(ARGV[0][1..-2])
13.    version = ARGV[0][1..-2]
14.    ARGV.shift
15.   end
16. end
17. require_gem 'rake', version
18. load 'rake' 


Things look like they are going downhill from here. First it was loosing my mysql connection, which still doesn't work, now this. sad

6

(12 replies, posted in Ruby on Rails)

Something went wrong somewhere. As you can see below, I have Gems 1.3.1, Rails 2.2.2 and Ruby 1.8.4. When I try to launch the server, it fails.


$ gem update rails --include-dependencies
Updating installed gems
Nothing to update
$ which ruby
/usr/local/bin/ruby
$ which rails
/usr/local/bin/rails
$ gem -v
1.3.1
$ rails -v
Rails 2.2.2
$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
$ script/server
./script/../config/boot.rb:25:Warning: Gem::SourceIndex#search support for String patterns is deprecated
./script/../config/boot.rb:28: undefined method `require_gem' for main:Object (NoMethodError)
        from script/server:2
$

I tried setting my gems with 1.2.6 and 1.3.1 but the same error. Should I be running Ruby 1.8.6?

7

(12 replies, posted in Ruby on Rails)

Robert, I ran your suggestions, which updated my gems to 1.3.1. I'm running Ruby 1.8.4 and have gems 1.3.1 installed. I think I messed up my Rails install. When I check the version ($rails -v), I'm getting the following error:

$/user/local/bin/rails:17: undefined method 'require_gem' for main:Object (NoMethodError)

I believe I'm going to have to rebuild my Rails. Do you have experience with MacPorts or Fink for updating Rails? If so, what has been your experience?

8

(12 replies, posted in Ruby on Rails)

Robert,

Here is my setup. I get the following error message when getting my rails version. By the way, MySQL is installed and is only available to my app. I can't use YourSQL any more to access my db.

localhost:~ aaronhyde$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
localhost:~ aaronhyde$ rails -v
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor.rb:5: undefined method `gem' for main:Object (NoMethodError)
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support.rb:24
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record.rb:25
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:181:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:167:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:166:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:31:in `require_gem'
        from /usr/local/bin/rails:17


Does that error look familiar?

After months of delay, I finally update to Rails 2.2.2. Until now I was running 1.2.6, which I built on my PowerMac Dual G5, OS 10.4.11 using the method from Hivelogic's site that uses Xcode. It has been solid until now.

Now that I've upgraded MySQL no longer works. I've install the MySQL gem 2.7. I get the following message:

$ gem install mysql
Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
Select which gem to install for your platform (powerpc-darwin8.7.0)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. mysql 2.5.1 (ruby)
6. Cancel installation
> 3
Building native extensions.  This could take a while...
ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

make
make: Nothing to be done for `all'.

make install
make: Nothing to be done for `install'.
Successfully installed mysql-2.7

On another note, when I attempted updating Ruby, I receive the follow error message:

$ gem update ruby --include-dependencies
Upgrading installed gems...
Attempting remote upgrade of ruby
Attempting remote installation of 'ruby'
ERROR:  While executing gem ... (Gem::GemNotFoundException)
    Could not find ruby (> 0) in the repository



I've tried connecting to my db using YourSQL and it doesn't work either. I would appreciate any help from the Mac users.

Thanks,
Aaron

I recently moved back to the San Jose, CA area and I'm looking to meet other Christian web professionals. If you know of any Meetup or other types of groups in the area, please let me know.

Aaron

11

(2 replies, posted in Ruby on Rails)

Kenny, you da' man. I knew someone here would know the answer.

Thanks....Aaron

12

(2 replies, posted in Ruby on Rails)

Does anyone know of a good resource that list all of the migration commands for updating/modifying your database with migrations? I understand the concept but I haven't found a source that list what I can do.

13

(5 replies, posted in Ruby on Rails)

I like the site, especially the breadcrumbs. It took me less than a minute to drop it in and test. Worked like a charm!

14

(4 replies, posted in Ruby on Rails)

Ryan, I did try it but had no success. I stepped through the tutorial and was able to get the first step working but not the second part. After several attempts, I posted questions on a forum board of the developer but didn't get a reply so I bailed out on using it. I know that others have gotten it to work for them.

It would have been nice to use. Not using it has forced me to learn more about RoR which has help push me up the learning curve.

15

(4 replies, posted in Ruby on Rails)

I thought I would respond with a better test for checking weather an upload file field is empty or is a StringIO object. Here is a change to my previous post.

         unless @picture.kind_of? StringIO or @picture.blank?

16

(11 replies, posted in Ruby on Rails)

I rolled my own build like Robert for the reasons stated on Hivelogic and everything is working fine. Depending on your Internet connection and your system configuration, you could build your own in about an hour or less in you have Apples Xcode installed. Add a few extra minutes to install Xcode in you don't have it installed already. Xcode is included on the Developer Tools CD that came with your system installer disc set.

17

(4 replies, posted in Ruby on Rails)

I believe I found my answer. Hopefully this will help someone else.

http://blog.vixiom.com/2006/07/26/rails … le-upload/

One thing I would suggest adding is testing to see if the uploaded field is a blank string. I noticed during testing that sometimes I would get a StringIO object and other times a blank string when I updated a record but didn't update the image, so I added a test for this like the following:

    unless @picture.kind_of? StringIO or picture == ""
      (do your upload processing)
      :
      :
    end

I'm using a modified version of the upload recipe from the Rails Recipe book. One thing that it doesn't include is testing for cases such as a blank upload field.


Aaron

18

(4 replies, posted in Ruby on Rails)

I have a form that I use for uploading images. I'm using a model attribute called "picture" that processes the uploaded file to disk and saves a reference to it in the database. When I try to update the same record without including a picture in the same form but when the record is updated I get an error. It appears that when creating a new record, the image file is processed correctly but when I tried to update the record without updating the picture, the empty "picture" attribute is returned as a StringIO object, causing an error. I've tried testing the empty "picture" object for being nil to bypass processing it but "!= nil" is failing. I haven't found a StringIO method that will let me test for a nil object. I would appreciate any help here.

Aaron

Okay. I found the solution to my problem and frustration. After reading AWD (around page 369-70), I got the impression that layouts can exist anywhere as long as you provide a complete path to the layout. What I discovered is that it's true IF it is in a subdirectory under "app/views". I was trying to keep user data for rendering layouts together outside of the views directory. I moved them into "app/views/" into a subdirectory and things are working fine.

It appears that the layout method is hard wired to look for any layouts or partials within the "views" directory of your application. It makes sense and it cold have only been my misunderstanding. I tried the render ...:layout => 'path to layout' option, which didn't work either. I lost a couple of days but it didn't have a major impact on what I want to accomplish. As a matter of fact, as I was trying different approaches to make my solution work, I discovered a couple of things that will make life a little easier for rendering views which I may not have discovered without going through the process.

Thanks again to Robert for the ready assistance and great list of resources.

By the way, here is something related that I found. http://rubyforge.org/tracker/index.php? … ;atid=3149

The only thing that I can think of is the upgrade. I thought it may be related to some mapping I add in routes.rb but I commented those additions out and still got it. The file that it's looking for is there. I decided I'm going to step away for a little while, let the cob web's clear a little then step back in with a fresh look to see what I may be overlooking. When I discover it, I will post it so that someone can learn from my experience.

By the way, thanks for all of the resources. As I was scanning the list, I felt like I was drinking from a firehose.

Something must be wrong. I tried you code and I'm still getting the error. It has to be related to the upgrade from rails 1.1.4 to 1.1.6 because this was working before the upgrade.

Robert. I will check it out and probably do the upgrade. By the way, what would you recommend for the better sources of information (mailing list, sites, etc.) to stay on top of the latest with RoR? Being that I'm new to RoR and learning it as I am working on my project, I need to stay in the loop of communications.

On another note, what would you suggest as RoR best practices? I know that I should be using Subversion (I have it downloaded but haven't started using it yet) and Capistrano (I haven't gotten to the point of needed it yet). I would appreciate any tips.

Thanks again,
Aaron

Thanks Robert. I will give it a try. I found this discussion that says that Rails 1.1.6 has a bug that has broken layouts. It appears to have broken a number of sites using ActionMailer when it trys to find a layout.

http://rubyforge.org/pipermail/rspec-us … vember.txt

Aaron

I have a controller that I want to dynamically change the layout based on a session parameter. I'm creating a session variable that has the path to the layout for the controller.

layout   :set_layout
:
: (Other actions)
:
def set_layout
    "#{session[:layout]}"
end

When the controller is passed control, I call set_layout to determine the layout to use but I keep getting the following error when the layout and partial exist. After doing some googling, it appears there can be any number of causes for the problem. I just haven't found one related to my situation. I'm not using ActionMailer, which seems to be the most common problem where this has been occuring.

"No rhtml, rxml, rjs or delegate template found for /Users/......./_home"


/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:389:in `find_template_extension_for'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:325:in `pick_template_extension'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:240:in `render_file'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:266:in `render'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:59:in `render_partial'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:29:in `benchmark'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/1.8/benchmark.rb:307:in `realtime'


Do controller layouts have to live in the applications layout directory or can it live out of it? I use the "shared" folder in "layouts" with no problem. Is this something totally unrelated to where the layout is located?