hi thorsten

on console i have tried below commonds:

>>Article.find(1)
working fine
>>article.tag_list
giving error like unfdefined local variable or method article
But if i check the tas table from mysql prompt i am able to see the
tag names like xx,yy....

i tried to give the tag names like
>>article.tag_list = "fun serious "
here also giving the same error but i trie yester in the same way it
showned like
["fun","serious"]

can u tell me how togive the tag name on console without using
article.tag_with method because this method not working.

thanks

On Thu, Dec 4, 2008 at 10:45 AM, sreekanth. G <[EMAIL PROTECTED]> wrote:
> Hi Thorsten,
>
> really very helpful ur ideas to me as i am very new to rails and sql.
>
> I HAVE UPDATED MY APPLICATION LIKE BELOW as per ur suggetions:
>
> 1)I added this search :map.resources :articles, :collection =>
> [:search] in route.rb like below
>
> map.connect ':controller/:action/:id'
>  map.connect ':controller/:action/:id.:format'
>  #added for search
>  map.resources :articles, :collection => [:search]
> end
> 2)i defined a search method in article controller like below:
>
> def search
> @articles = Article.find_tagged_with(params[:search])
> end
>
> 3)i added the below code in idex.html.erb as u said and added a
> commond to get a search box for tag entry.
>
> Search: <input type="text" id="search_form" name="search" />
>
> <% form_tag(search_articles_path(), :method => :get) do %>
>  <%= label(:search, :tag, "Search:") %><br />
>  <input name="search" id="tag" type="text" size="17" value='<%=
> session[:search_keys] %>' style="width:123px;" />
>  <input type="image" id="bt_zoek" src="/images/search.jpg"
> alt="search" style="border:none;"/>
> <% end %>
>
> then i trid http://localhost:3000/articles
>
> i am able to see on index page like below list:
>
> Listing articles
> Name          Body
> Cricket  india vs pak tour  Show Edit Destroy
> politics  HM quits            Show Edit Destroy
>
> New article
>
> Search:
>
>
>
>
> from the index page i am able to do show,edit,destory and new article
> functionalities and i am getting the search box to enter a tag name.
>
> then my quiries:
> 1)if i enter some tag name then i press the search button  i m getting
> erors like:
>
> ActiveRecord::RecordNotFound in ArticlesController#show
> Couldn't find Article with ID=search
> RAILS_ROOT: E:/srikanth/InstantRails-2.0-win/rails_apps/blog
> RequestParameters:
> {"search"=>"fun",
>  "x"=>"48",
>  "y"=>"18",
>  "id"=>"search"}
>
> 2)if the search isable to do searching  then the reasult shoud be list
> out on index rt.so for this do we need update in any one of views(to
> get the results) can u tell me which view i ned to modify and how ?
>
> 3)small doubt:
>
> i have a table like contacts with columns like:
>
> id name age location
> 1  a       12   ap
> 2  b        13  ap
> 3  c        12  up
>
> corresponding tag table like:
> id name
> 1  xx
> 2  yy
> 3  zz
>
> here my douts are
> 1)the tag name shoud be one of the parameter like name or age or place
> or it should be the entry name of perticuler column?
> here actaully i given tag name as fun and serious as tag names but we
> did not mention any relation table contents of article ,even if i do
> article.find_taggable_with('fun') it is giving the details of teble
> entrys.i did not understand the logic here can u help in this?
>
> thanks
> Srikanth
> 2)suppose i want to find all people from place ap i want to search
> ,how can i do that?
> 3)how the taging table is updating with all the above columns in the
> tagging table?
>
>
> tagging table like:
> id tid taggable_id taggable_type
>
>
>
> On Wed, Dec 3, 2008 at 7:07 PM, Thorsten Müller <[EMAIL PROTECTED]> wrote:
>>
>>> You mean to say i need to add
>>> 1)map.resources :articles, :collection => [:search] in route.rb
>>
>> yes
>>
>>> 2)do i need to add method in controller like
>>>
>>> def get
>>> -----
>>> end
>>
>> no, it should be:
>> def search
>> ...
>> end
>>
>> the :collection => [:search]
>> declares the existence of this search method in the articles
>> controller
>>
>>>
>>> 3)Can we give the tag parameter as text box entry from the
>>> forms(index.html.erb) and that tag parameter can be searched in the
>>> database?
>>>
>>
>> yes, if you have a textbox named "search", then
>> params[:search]
>> will have the text entered in this box. You
>> can give it any other name of course, params will have the value
>> with the same name.
>> (You can see what params are returned in the development.log)
>>
>> To use this for searching:
>> @articles = Article.find_tagged_with(params[:search])
>>
>> then you should have all artcles with that tag in @articles
>> and can display them in the view
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to