How to redirect with multiple controller

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to redirect with multiple controller

daynthan kabilan
Hi,

I have two controllers

1,  api/risk_profiles
2,  admin/risk_profiles

When i submitted a form then a new record was created in 'api/risk_profiles'  controller and the action name 'create'.

Now, i want to redirect to 'admin/risk_profiles' show action. Because i have upload some API process is there. currently i have used the below codes but it not performed



def create
    @risk_profile = RiskProfile.new(risk_profile_params)

    if @risk_profile.save
          redirect_to api_risk_profiles_url(:id => @risk_profile) 
    end
  end



Note:

Rails console result
Daya

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADKeJyQ2%3D3w-Hh%3DSNYs6KhZbNa9hCHG9jERdVAtagp0YKnjsjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to redirect with multiple controller

Hassan Schroeder-2
On Mon, Mar 12, 2018 at 7:31 AM, Daynthan Kabilan <[hidden email]> wrote:

> I have two controllers
>
> 1,  api/risk_profiles
> 2,  admin/risk_profiles
>
> When i submitted a form then a new record was created in 'api/risk_profiles'
> controller and the action name 'create'.
>
> Now, i want to redirect to 'admin/risk_profiles' show action. Because i have
> upload some API process is there. currently i have used the below codes but
> it not performed

?? The "below codes" don't match what you're saying you want to do.

> def create
>     @risk_profile = RiskProfile.new(risk_profile_params)
>
>     if @risk_profile.save
>           redirect_to api_risk_profiles_url(:id => @risk_profile)
>     end
>   end

but the result below looks like it matches the redirect code above

> Rails console result
> 19:49:48 rails.1   | Redirected to
> http://localhost:5000/api/risk_profiles?id=304046b8-fd04-4310-b475-636ac60d111a

So which is correct, the code or your description?

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCzXvGAFyuiK0SbsW%3DvusdWCyTAmBpsNHxG9%2BJ%3DVH9NcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to redirect with multiple controller

daynthan kabilan
Thanks for your reply Hassan,

I got the solution using helper method.

Actually admin should upload the user details to another site manually
Now my clients need the upload process also performed when user was created a form.
So, currently i have moved the codes into helper and access in both functionality(manual and automatic).

On Mon, Mar 12, 2018 at 8:45 PM, Hassan Schroeder <[hidden email]> wrote:
On Mon, Mar 12, 2018 at 7:31 AM, Daynthan Kabilan <[hidden email]> wrote:

> I have two controllers
>
> 1,  api/risk_profiles
> 2,  admin/risk_profiles
>
> When i submitted a form then a new record was created in 'api/risk_profiles'
> controller and the action name 'create'.
>
> Now, i want to redirect to 'admin/risk_profiles' show action. Because i have
> upload some API process is there. currently i have used the below codes but
> it not performed

?? The "below codes" don't match what you're saying you want to do.

> def create
>     @risk_profile = RiskProfile.new(risk_profile_params)
>
>     if @risk_profile.save
>           redirect_to api_risk_profiles_url(:id => @risk_profile)
>     end
>   end

but the result below looks like it matches the redirect code above

> Rails console result
> 19:49:48 rails.1   | Redirected to
> http://localhost:5000/api/risk_profiles?id=304046b8-fd04-4310-b475-636ac60d111a

So which is correct, the code or your description?

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCzXvGAFyuiK0SbsW%3DvusdWCyTAmBpsNHxG9%2BJ%3DVH9NcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADKeJyRTrZa6PSqwEY0DjVcCuoN8XBe3o5XesscOVy2otbTCkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.