Problem in accessing "create" action

I had developed one web application using scaffold…Application
consists one controller(BOOKS). In BOOK controller 7 action are
presented(new,create,show,edit,destroy,list,index)…correspondingly in
views under BOOKS folder 4 rhtml files presented(
new.rhtml,list.rhtml,show.rthml,edit.rhtml)…I can able to access all
the actions(create,new,show…etc) presented in BOOKS controller from
views(rhtml files)…But i could not able to access “create” action from
other action(new,show,…etc) presented in BOOKS controller…i can able
to access remaining actions from different action in BOOKS controller…
How to access “create” action from other action in BOOKS controller?

On 15 March 2012 03:57, Mahes karthick [email protected] wrote:

I had developed one web application using scaffold…Application
consists one controller(BOOKS). In BOOK controller 7 action are
presented(new,create,show,edit,destroy,list,index)…correspondingly in
views under BOOKS folder 4 rhtml files presented(
new.rhtml,list.rhtml,show.rthml,edit.rhtml)…I can able to access all
the actions(create,new,show…etc) presented in BOOKS controller from
views(rhtml files)…But i could not able to access “create” action from
other action(new,show,…etc) presented in BOOKS controller…i can able
to access remaining actions from different action in BOOKS controller…
How to access “create” action from other action in BOOKS controller?

What do you mean you wan to access the create action from another
action? Normally one does not access one action from another.
Normally one would invoke an action from a view by including an
appropriate link in the view. When asking questions about technical
subjects it is necessary to be very careful with choice of words so
that the question is understood. One way to ensure this is to give an
example.

I suggest that you work through some tutorials in order to understand
the basics of rails. railstutorial.org is good and is free to use
online (though you have to look for the link for free online use).

Also have a look at the Rails Guides.

Colin

Sorry for not be clear in MY question…
i couldn’t able to transfer control to create action from another
actions by using redirect_to method…
i can able to pass parameters from Web pages to create action by
clicking create button.

Example of my controller

class LoginController < ApplicationController
def new
redirect_to :action=>create,:parameter1=>value1,:parameter2=>value2
end
def create

end
def show
end
.
.
.
def edit
end
end

From new action i couldn’t able transfer control to redirect to create
action.

Example of Web page

create action was able to access only by clicking "Create" button in Web page

On 16 March 2012 13:45, Mahes karthick [email protected] wrote:

Please don’t top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message. Thanks.

redirect_to :action=>create,:parameter1=>value1,:parameter2=>value2
You are still not being very clear, do you just mean that the line
above does not work? It should be :action => ‘create’

If it still is not right and you get an error show us the full error,
if you don’t get an error but it does not seem to be working have a
look in development.log to see what is going on.

end

create action was able to access only by clicking "Create" button in Web page

I don’t understand why you have shown us the code above.

Colin

The code which you written, are correct. write code step by step and
debug. Try to identify issues. See dovelopmet.log file,

class LoginController < ApplicationController
def new
redirect_to :action=>create
end
def create
raise “testing”

end
def show
end
.
.
.
def edit
end
end

run this code, added code one by one making sure previous written code
are correct.

http://guides.rubyonrails.org/layouts_and_rendering.html
(2.3 Using redirect_to)

http://guides.rubyonrails.org/routing.html
(2.2 CRUD, Verbs, and Actions)

read above section and try to understand how redirect_to and routers
works.

Colin L. wrote in post #1051854:

On 16 March 2012 13:45, Mahes karthick [email protected] wrote:

Please don’t top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message. Thanks.

redirect_to :action=>create,:parameter1=>value1,:parameter2=>value2
You are still not being very clear, do you just mean that the line
above does not work? It should be :action => ‘create’

If it still is not right and you get an error show us the full error,
if you don’t get an error but it does not seem to be working have a
look in development.log to see what is going on.

end

create action was able to access only by clicking "Create" button in Web page

I don’t understand why you have shown us the code above.

Colin

redirect_to :action=>create,:parameter1=>value1,:parameter2=>value2

this line does not working…when im redirecting to create action from
new action…it does not invoking create action…

>> >> >> >> >> >> >> >> create action was able to access only by clicking "Create" button in Web >> page

i had shown this to make clear my question…from Web page i can able to
invoke the create action…but i couldn’t able to invoke the create
action from some other action.

On 19 March 2012 14:15, Mahes karthick [email protected] wrote:

If it still is not right and you get an error show us the full error,

redirect_to :action=>create,:parameter1=>value1,:parameter2=>value2

this line does not working…when im redirecting to create action from
new action…it does not invoking create action…

Did you not see my comment last time, It should be :action => ‘create’

If it still does not work look in development.log and see what is
happening. Also look at the Rails Guide on Debugging. That will show
you ways of debugging your code.

Colin

Once take a look to this url
http://guides.rubyonrails.org/layouts_and_rendering.html
(2.3 Using redirect_to)

Instead of redirect_to
:action=>create,:parameter1=>value1,:parameter2=>value2
use redirect_to :action=>‘create’ and in create method

def create
raise “testing”
end

it supposed to raise exception if not your router is not define
properly.

http://guides.rubyonrails.org/routing.html
(2.2 CRUD, Verbs, and Actions)

Colin L. wrote in post #1052299:

On 19 March 2012 14:15, Mahes karthick [email protected] wrote:

If it still is not right and you get an error show us the full error,

redirect_to :action=>create,:parameter1=>value1,:parameter2=>value2

this line does not working…when im redirecting to create action from
new action…it does not invoking create action…

Did you not see my comment last time, It should be :action => ‘create’

If it still does not work look in development.log and see what is
happening. Also look at the Rails Guide on Debugging. That will show
you ways of debugging your code.

Colin

:action => ‘create’…i had given same code…but still i couldn’t able
to invoke the create action…i will see development.log and debugging
files.
Thank you very much for your help…

Pravin M. wrote in post #1052315:

Once take a look to this url
http://guides.rubyonrails.org/layouts_and_rendering.html
(2.3 Using redirect_to)

Instead of redirect_to
:action=>create,:parameter1=>value1,:parameter2=>value2
use redirect_to :action=>‘create’ and in create method

def create
raise “testing”
end

it supposed to raise exception if not your router is not define
properly.

http://guides.rubyonrails.org/routing.html
(2.2 CRUD, Verbs, and Actions)

i will try this code and check it…
thanks for your guidelines…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs