On 08/12/2007, aa geboi_2 <[EMAIL PROTECTED]> wrote:
> saya pny masalah di aplikasi rails saya, saya ingin munculin type diambil
> dari tabel type ke dalam
> select box. jadi option di dlm select tu datany dr tabel type. diambilnya dr
> controller browse.
>
> BrowseController:
> class BrowseController < ApplicationController
> def category
> @category = Category.find(params[:id])
> end
> def package_summary
> @package = Package.find(params[:id])
> end
> def itinerary
> @package = Package.find(params[:id])
> end
> def groups
> @package = Package.find(params[:id])
> end
> def tour
> @tour = Tour.find(params[:id])
> end
> end
damn! 3 redundant same purpose action methods!
class BrowseController < ApplicationController
before_filter :load_package, :only => [ :package_summary, :itinerary, :groups]
def category
@category = Category.find(params[:id])
end
def package_summary
end
def itinerary
end
def groups
end
def tour
@tour = Tour.find(params[:id])
end
protected
def load_package
@package = Package.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:error] = 'Package not found!'
redirect_to root_url
end
end
> muncul error seperti ini ketika masuk ke
> http://localhost:3000/browse/tour/116, yaitu halaman di mana akan ditampilin
> select box nya.
>
> uninitialized constant ActionView::Base::CompiledTemplates::Type
> Extracted source (around line #21):
>
> potongan file tour.rhtml nya :
>
> 18:
> 19: <label for="group_type">Affinity</label>
> 20: <%= f.collection_select :type_id,
> 21: Type.find_all,
> 22: :id,
> 23: :name %>
<%= f.select :type_id, Type.find(:all).map { |e| [ e.name, e.id ] } %>
--
Arie | http://linkedin.com/in/ariekeren | http://profile.to/ariekeren/
http://ariekusumaatmaja.wordpress.com | http://groups.yahoo.com/groups/id-ruby