Recent Posts

Subscribe to Recent Posts 485 post(s) found

Pages: 1 2 3 4 5 6 7 8 9 10 11 ... 20

May 2, 2010
Avatar alex 1 post

Topic: Exercisr Discussion / An error adding activities.

Hello. I am actually having this exact same problem. I’ve been looking at this error for 3 hours, and really, even though I’ve made some progress, I’m frankly at a loss.

I know this topic is about a year old… but can I still get some input?

The error is:

Couldn’t find Workout without an ID

and my routes looks like this:

bq.(ActionController::Routing::Routes.draw do |map| map.resources :activities

map.resources :workouts do |workout|
  workout.resources :activities
end
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.resources :users
map.welcome '/welcome', :controller => 'sessions', :action => 'welcome'
map.resource :session
map.resources :exercises
  1. The priority is based upon order of creation: first created -> highest priority.
  1. Sample of regular route:
  2. map.connect ‘products/:id’, :controller => ‘catalog’, :action => ‘view’
  3. Keep in mind you can assign values other than :controller and :action
  1. Sample of named route:
  2. map.purchase ‘products/:id/purchase’, :controller => ‘catalog’, :action => ‘purchase’
  3. This route can be invoked with purchase_url(:id => product.id)
  1. Sample resource route (maps HTTP verbs to controller actions automatically):
  2. map.resources :products
  1. Sample resource route with options:
  2. map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
  1. Sample resource route with sub-resources:
  2. map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  1. Sample resource route with more complex sub-resources
  2. map.resources :products do |products|
  3. products.resources :comments
  4. products.resources :sales, :collection => { :recent => :get }
  5. end
  1. Sample resource route within a namespace:
  2. map.namespace :admin do |admin|
  3. # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  4. admin.resources :products
  5. end
  1. You can have the root of your site routed with map.root—just remember to delete public/index.html. map.root :controller => “sessions”, :action => ‘new’
  1. See how all your routes lay out with “rake routes”
  1. Install the default routes as the lowest priority.
  2. Note: These default routes make all actions in every controller accessible via GET requests. You should
  3. consider removing or commenting them out if you’re using named routes and resources. map.connect ’:controller/:action/:id’ map.connect ’:controller/:action/:id.:format’
    end
    )
 
Apr 18, 2010
Avatar zoujm 2 post(s)

Topic: Announcements / aaa

I can do it
[url=http://www.ecsalesonline.com/wholesale-sport-jerseys-c-06.html] Wholesale Sport Jerseys [/url] I can do it
Wholesale Sport Jerseys I can do it [link=http://www.ecsalesonline.com/wholesale-nike-sneaker-c-014.html] Wholesale Nike Sneaker[/link] I can do it [Wholesale Sport Jerseys->http://www.ecsalesonline.com/wholesale-sport-jerseys-c-06.html]

 
Apr 18, 2010
Avatar zoujm 2 post(s)

Topic: Announcements / Starting New Book

I can do it
[url=http://www.ecsalesonline.com/wholesale-sport-jerseys-c-06.html] Wholesale Sport Jerseys [/url] I can do it
Wholesale Sport Jerseys I can do it [link=http://www.ecsalesonline.com/wholesale-nike-sneaker-c-014.html] Wholesale Nike Sneaker[/link] I can do it [Wholesale Sport Jerseys->http://www.ecsalesonline.com/wholesale-sport-jerseys-c-06.html]

 
Mar 29, 2010
Avatar EldonAlameda 216 post(s)

Topic: Introductions / Chapter 2 - Questions

Easiest way to find that CSS file would be to download the source files from the Apress book site and copy them out of there.

 
Mar 29, 2010
Avatar EldonAlameda 216 post(s)

Topic: Introductions / Chapter 2 - Questions

1. You can just use rake rails:freeze to freeze whichever version of Rails is specified in environment.rb (as long as it’s installed)
2. The edge was just a way to get to the “in development” versions of the gems.
3. The tag was used when Rails was still using subversion.
4. good question. It’s been a long time and I can’t recall if the older versions of Rails did allow that or not. Personally – I think it would be easier to ensure that it’s installed.

As for the figure – just a mistake as I was doing development for a company that used SQL Server at the time.

 
Mar 29, 2010
Avatar EldonAlameda 216 post(s)

Topic: Introductions / Good Books!

1.b You’re correct – With leopard Apple included an installation of SQLite so you don’t need to worry about installing it (just the ruby sqlite gem)

2. You don’t need to use mongrel_rails start. You can just use ruby script/server and it will start up Mongrel if it’s installed or Webrick if it’s not.

3. It’s been a couple of years but if memory serves me correctly there weren’t a lot of big differences between 1.2.3 and 1.2.6 (mainly just security fixes) When Rails went to 2.0 though, was when things began to change dramatically.

 
Mar 29, 2010
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / ruby script/generate controller today index

It sounds like a mismatch of Rails version to codebase. Are you running a newer version of Rails on the downloaded code?

 
Mar 28, 2010
Avatar supabok 2 post(s)

Topic: MonkeyTasks Discussion / Unable to send mail through SMTP

Thx for your reply Eldon.

I did try setting the delivery_method to :sendmail but that didn’t work either.
It seems the problem was my server setup.
When i switched to using gmail as my server it worked fine!
Thx again.
erick

 
Mar 27, 2010
Avatar Mung 5 post(s)

Topic: Announcements / Starting New Book

I know it’s a bit late for this. Your “new” book, Foundation Rails 2, is out. (Is there a web site for it?) But just in case you’re willing to write yet another one ;).

1. Working with multiple versions of ruby/rails.

2. Running multiple rails apps.

3. Accessing more than one database from a single app.

4. Working with non-rails-convention databases.

5. Non-trivial examples.

6. Database structuring.

This might be a good one for you with your background and ties in with #4. How do we employ good database design. Or how do we design our models such that good database design follows naturally from them? This probably requires one or more non-trivial applications since.

6. Test First Development

Very few, if any, books on rails I’ve seen seem to want to touch this. If rails is opinionated, and this is one of the things it’s opinionated about, it should be start from the outset. How do we write tests, and which tests do we write. Isn’t there a way to make writing tests fun? I would LOVE to see a rails book that shows how to write the tests as an application is constructed.

7. Documentation

Sort of goes hand-in-hand with #6 I think. Books on rails, even beginning ones, should come right out teaching how to document the code from the start, not as sort of an afterthought, if at all. That’s my opinion ;)

 
Mar 27, 2010
Avatar Mung 5 post(s)

Topic: Introductions / Chapter 2 - Questions

Chapter 2
Step 4: Install Style Sheets
Page 30

The book isn’t too clear on how to obtain the reset-fonts-grids.css file. I downloaded the entire YUI 2.8.0r4 Library and found the file in the yui/build/reset-fonts-grids/ folder.

 
Mar 27, 2010
Avatar Mung 5 post(s)

Topic: Introductions / Good Books!

1.a. SQLite3 on Windows
Forget that question. I found what I was looking for. Looks like it installed the correct gem for Windows.
sqlite3-ruby-1.2.5-x86-mingw32

 
Mar 27, 2010
Avatar Mung 5 post(s)

Topic: Introductions / Chapter 2 - Questions

Chapter 2
Step 5: Freeze Rails
Page 30

rake:rails:freeze:edge TAG=rel_1-2-3

Could you explain this a bit please?

1. If I have only version 1.2.3 of rails installed, would I use this exact same command?

2. What’s with the ”:edge” part?

3. What’s with the “TAG=” part?

4. Is it possible to freeze to a version of the rails gem that is not present locally on your machine?

Thanks!

p.s. If we’re using SQLite, why does Figure 2-1 on page 30 show sqlserver!? ;)

 
Mar 27, 2010
Avatar Mung 5 post(s)

Topic: Introductions / Good Books!

Yes, books. I am a good way through your Foundation Rails 2 book and really like it, so I ordered this one even though it’s a bit dated, and it came in today. I can already tell you that I am enjoying this one as well. I like the way you write, and the material that you provide in your books. In this book I love how you start right out saying you’re going to use SQLite. So many of the older Rails books make you use MySQL and don’t even hint at any other option, lol.

Just a few questions to get me started:

1. SQLite3

1.a. SQLite3 on Windows

Is there a special gem for SQLite3 for Windows?

Or do I do gem install sqlite3-ruby on Windows as well?

1.b. SQLite3 on Mac

Recently purchased a Mac with the latest OS X.

In the book on page 8 it talks about using MacPorts. “Before you can install the Ruby gem, you will need to install an application named SWIG. Otherwise the SQLite gem will not use the correct SQLite library…” Do I need to worry about this on the newer Mac? I’m pretty sure the gem is already installed, but is it the correct (best) one?

2. Mongrel

Do I still need to use mongrel_rails to start and stop?

I know the newer version or rails will use Mongrel automatically if it’s installed.

3. Rails Version

I installed version 1.2.3 since that’s the version mentioned in the book (see Figure 2-1 on page 29). It just so happens that version 1.2.3 also works for the RailsSpace book. Should 1.2.3 work out for this book, or should I install 1.2.6?

Thanks for the great books!

 
Mar 8, 2010
Avatar ianisborn 1 post

Topic: MonkeyTasks Discussion / ruby script/generate controller today index

Hey so on page 36 I run said command in monkey and I get the error:

/Users/ianhenrysmith/monkey/config/boot.rb:45:in `require’: no such file to load—/Users/ianhenrysmith/monkey/config/../vendor/rails/railties/lib/initializer (LoadError) from /Users/ianhenrysmith/monkey/config/boot.rb:45:in `load_initializer’ from /Users/ianhenrysmith/monkey/config/boot.rb:38:in `run’ from /Users/ianhenrysmith/monkey/config/boot.rb:11:in `boot!’ from /Users/ianhenrysmith/monkey/config/boot.rb:110 from script/generate:2:in `require’ from script/generate:2

Haven’t run into any problems so far setting up rails or the db or anything. Thanks!

 
Feb 22, 2010
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / Project with later versions

see this topic

 
Feb 22, 2010
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / 2.3.5 Compatible Monkey Tasks

I’ve had a number of people contact me over the last couple of months (which unfortunately have been far more hectic for me than usual) with questions about upgrading some of the books projects to the current version of Rails 2.3.5.

Since the projects in the book were all written in 1.2.6, and Rails has a bad habit of having non-backward compatible changes – this has caused some issues for people. Unfortunately – I don’t have time to update all the books projects but thought I would at least put together a Rails 2.3.5 compatible version of Monkey Tasks for people to use as a reference.

You can download it from here.

One key thing to remember is that this version is Rails 2.3.5 COMPATIBLE, which is quite different from being up to date with Rails 2.3.5 standards. A lot has changed in Rails and in how Rails developers build applications since the book was published and there were quite a few times during my updates that I was wanting to throw huge chunks of code away to update them to the newer standards, however I thought that might cause even more confusion so I kept my changes more in line with how the book was written.

 
Feb 22, 2010
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / NoMethodError in TaskController#mark_complete

Adding link to an Rails 2.3.5 version of the Monkey Tasks project – you might want to check it’s source out and compare it against yours.

 
Feb 22, 2010
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / Unable to send mail through SMTP

Have you tried setting action_mailer to user sendmail instead?

i.e. in environment.rb

  config.action_mailer.delivery_method = :sendmail

 
Feb 18, 2010
Avatar Hunt Norment 2 post(s)

Topic: MonkeyTasks Discussion / NoMethodError in TaskController#mark_complete

fixed. never mind. except i notice that when I mark a task as complete, I need to click the browser refresh button to strike it and move it to the bottom. I also notice in the console that the complete variable is always null.

 
Feb 18, 2010
Avatar Hunt Norment 2 post(s)

Topic: MonkeyTasks Discussion / NoMethodError in TaskController#mark_complete

Just added the mark_complete method to the task controller and get this error message every time. Here is the snippet:

def mark_complete if @task.complete.nil? @task.complete = Time.now <- this line is the culprit -> @task.todo.move_to_bottom else @task.complete = nil end @task.save! redirect_to :controller => :today, :action => :index end

It must be something syntactical. Any ideas?

 
Jan 25, 2010
Avatar supabok 2 post(s)

Topic: MonkeyTasks Discussion / Unable to send mail through SMTP

Hi all..
I’ve completed chapter 3 and am so close to moving on but unfortunatley I can’t
complete the signup process cuz i keep getting this error:

Net::SMTPUnknownError in AccountController#signup

C:/Ruby/lib/ruby/1.8/net/smtp.rb:679:in `check_response’
C:/Ruby/lib/ruby/1.8/net/smtp.rb:395:in `do_start’
C:/Ruby/lib/ruby/1.8/net/smtp.rb:377:in `start’
C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:682:in `perform_delivery_smtp’
C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:523:in `send
C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:523:in `deliver!’
C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:395:in `method_missing’
E:/rails/monkey/app/models/user_observer.rb:3:in `after_create’
E:/rails/monkey/app/controllers/account_controller.rb:24:in `signup’

I’ve checked the code over many times and it seems to be fine :(
Can anyone shed some light on what i might be missing or doing wrong??
Thx
erick

 
Jan 13, 2010
Avatar Andy Stephenson 1 post

Topic: MonkeyTasks Discussion / Project with later versions

Hi,

I have installed Rails 2.3.5 and ruby 1.9.1 into a ubuntu virtual box.

I was OK upto page 74, but @todos = @today.todos casued a problem. That turned out to be because I did not have the acts_as_list plugin.

I got further errors that seemed to stem from the tasks I created, so I cleared out the tables in sqlite3 to start again.

Now I get:
Processing TodayController#index (for 127.0.0.1 at 2010-01-13 15:59:15) [GET] User Load (0.5ms) SELECT * FROM “users” WHERE (“users”.”id” = 1) LIMIT 1 Schedule Load (2.3ms) SELECT * FROM “schedules” WHERE (“schedules”.user_id = 1 AND (today = ‘2010-01-13’)) LIMIT 1 Todo Load (0.3ms) SELECT * FROM “todos” WHERE (schedule_id IS NULL) ORDER BY position DESC LIMIT 1 Todo Create (0.5ms) INSERT INTO “todos” (“schedule_id”, “task_id”, “position”) VALUES

TypeError (nil is not a symbol): app/models/todo.rb:6:in `<class:todo>‘ app/models/todo.rb:1:in `<top>‘ app/controllers/today_controller.rb:6:in `index’ <internal:prelude>:8:in `synchronize’ /home/andy/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service’ /home/andy/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run’ /home/andy/.rvm/ruby-1.9.1-p376/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread’

I tried the complete source from the website in a different directory, but it was not happy with my version.

Anyone got this project to work in the ruby and rails versions indicated?

...Andy

 
Aug 19, 2009
Avatar mongo 8 post(s)

Topic: Church Community Discussion / small_avatar problems

I found another solution that did not involve the config/environments/development.rb change for config.cache_classes = true…
I have no idea why it works, but it fixed the problem in my setup (Linux, MySQL, mongrel_rails…). This was an especially frustrating problem because sometimes it would work (immediately after a server restart), then on any page refresh it would fail.

Take the comment.rb file from vendor/plugins/acts_as_commentable/lib directory and move it to app/models/comment.rb
Restart your server (mongrel_rails restart) and it should do the trick. Now the comment.user model will behave as a “proper” user object, having the correct methods and attributed available to the template.

 
Aug 4, 2009
Avatar kmandrup 1 post

Topic: GamingTrend Discussion / Refactoring suggestions

I have just been looking into the source of GamingTrends, since I want to use Rails with ExtJS and find it a somewhat good inspiration.

To get up and running I first had to setup the MySql database with the schema. I had problems using the migrations. I got some errors on the E304 and descrip index og Games. (BLOG/TEXT requires a length key, tried adding a :limit => 1000, but didn’t work!?)

To import the schema into a mysql database, I recommend removing Games indexes “E304” and “descrip” from the first migration. They are deleted on the cleanup migrations anyways!

Finally I got the app up and running, but I was unable to create Posts!

in the source code
/app/views/post/index.rhtml
- Contains Headline x 2, missing FrontPage attribute, title should be “Create New Story”

/app/views/post/new.rhtml
- Same errors as in index.rhtml, replace second (duplicate) “Headline” with “FrontPage”

Looking into the code:

I feel the ExtJS infrastructure can be vastly improved by scrapping the ext helper function in application_helper.rb and refactoring them.
The current design is not very DRY and the multiple ” function << ...” statements to build up the ExtJS javascript is not exactly pretty.

I came up with the following refactoring solution:
--------

application_helper.rb
--— # model, primary_key, fields, columns, height, width, pageSize, newsFun def ext_grid(options = {}) xml_fields = fields xml_fields << primary_key xml_fields.collect! {|x| ”’#{x}’”} models = model.pluralize options.merge!(xml_fields, models) render_ext_js(‘ext_grid’, options) render_ext_js(‘news_fun’, options) if newsFun end

def render_ext_js(name, options)
  javascript_tag(render(:partial => "shared/ext_grid", :locals => options))
end

games/index.rhtml
---

<= ext_layout(‘Games’) %>
<
= ext_grid(:optons => {:model => “game”, :primary_key => “GameID”, :fields => %w(Title Console), :columns => “{header: ‘Title’, width: 300, dataIndex: ‘Title’}, {header: ‘Console’, width: 250, dataIndex: ‘Console’}”, :height => 340, :width => 530, :pageSize => 13}) %>

shared/_ext_grid.rhtml
----
var pageGrid = function() { var grid; var dialog; var ds;

return { 
    init : function(){
         ds = new Ext.data.Store({    
         proxy: new Ext.data.HttpProxy({
            method: 'GET', 
            url: '<%= models %>.json'}),
            reader: new Ext.data.JsonReader({
                root: '<%= models %>',
                 totalProperty: 'totalCount',
                 id: '<%= primary_key %>'
            }, 
}
}();
});    
var cm = new Ext.grid.ColumnModel([<%= columns %>]);
cm.defaultSortable = true;
grid = new Ext.grid.Grid(
    'content', 
    { ds: ds, cm: cm }
);    
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
var paging = new Ext.PagingToolbar(gridFoot, ds, {
    pageSize: <%= pageSize %>,
    displayInfo: true,
    displayMsg: 'Displaying topics {0} - {1} of {2}',    
    emptyMsg: 'No topics to display'
});
ds.load({
    params:{start:0, limit:<%= pageSize %>}
});
grid.on('rowdblclick', editResource);
var gridHead = grid.getView().getHeaderPanel(true);
var tb = new Ext.Toolbar(gridHead);
tb.add(
    { 
        text: 'Create New <%= model %>', 
        handler: createResource 
    }, 
    '-', 
    { 
        text: 'Delete Selected  <%= model %>', 
        handler: deleteResource 
    }
);
tb.add(
    '-', 
    'Filter: ', 
    "<input type="text" id="text_filter">" 
);
Ext.get('text_filter').on('keyup', filterResource);
}

PageGrid.filterResource = function() { filtervalue = Ext.get(‘text_filter’).dom.value; ds.proxy = new Ext.data.HttpProxy({ method: ‘GET’, url: ‘<%= models %>.json?search=’ + filtervalue} ); ds.reload();
}

PageGrid.deleteResource = function() { var id = grid.getSelectionModel().getSelected(); if(id){ Ext.MessageBox.confirm(‘Confirm’, ‘Are you sure you want to delete this <%= model %>?’, postDelete); } else { Ext.MessageBox.alert(‘DOH!’, ‘Maybe you want to try again after ACTUALLY selecting something?’) }
}

PageGrid.submitResource = function(){ document.create_resource.submit();
}

PageGrid.postDelete = function(btn){ if(btn == ‘yes’) { var id = grid.getSelectionModel().getSelected(); var deleteme = id.get(‘<%= primary_key %>‘); window.location.href = ’/<%= models %>/destroy/’ + deleteme; }
}

PageGrid.editResource = function (grid, rowIndex) { var id = grid.getSelectionModel().getSelected(); if(id) { window.location.href = ’/<= models %>/’ + id.get(‘<= primary_key %>‘); }
}
// width:500, 630, pageSize:13, 20
PageGrid.createResource = function() { if(!dialog) { dialog = new Ext.BasicDialog(‘newDialog’, { width: <%= width %>, height:<%= height %>, shadow:true, minWidth:300, minHeight:<%= height %>, proxyDrag:true, autoScroll:false, animEl:true }); dialog.addKeyListener(27, dialog.hide, dialog); postBtn = dialog.addButton(‘Submit’, submitResource, this); dialog.addButton(‘Close’, dialog.hide, dialog); } dialog.show(); dialog.on(‘hide’, function(){ document.create_resource.reset(); })
}

Ext.onReady(pageGrid.init, pageGrid, true);

shared/_news_fun.rhtml
---

PageGrid.renderNews = function(value, p, record) { return String.format(‘{0}
{1}’, value, Ext.util.Format.stripTags(record.data[‘Body’]).substr(0,100) + ”....”);
}

PageGrid.renderNewsPlain = function(value) { return String.format(‘{0}’, value);
}

PageGrid.toggleNews = function(btn, pressed) { cm.getColumnById(‘Headline’).renderer = pressed ? renderNews : renderNewsPlain; grid.getView().refresh();
}

var formatBoolean = function (value) { return (value == 1) ? ‘Yes’ : ‘IMO. I will see where I get from here…

 
Jul 24, 2009
Avatar EldonAlameda 216 post(s)

Topic: Exercisr Discussion / An error adding activities.

Crap – I got so swamped at work that I completely forgot about this problem. So my apologies to Mongo for not looking into this.

If GruffDavies is correct and it’s simply a matter of the named route helpers that are generated are incorrect that would make sense. This book was written using Rails 1.2.6, and there were some minor changes to those routes in the early 2.x days. One of which was the automatic pre-fixing of nested routes with the parent routes name.

And Gruff – yes you should be able to use the shorthand version of :has_many in route generation now as well (also added to Rails after the book was published). You can use the shortcut has_one to link to a singular nested resource and a has_many to link to a collection nested resource. (However – I will note that I rarely see this idiom used). As for why it wasn’t working for you – I think you’re missing a comma between :workouts and :has_many.

Hope that helps – once again sorry for forgetting about this.

Next Page

Pages: 1 2 3 4 5 6 7 8 9 10 11 ... 20