I added postmark to my Ruby On rails app. I followed the steps from the page https://devcenter.heroku.com/articles/postmark#sending-emails-in-ruby-on-rails-3-x . Now I need to add the following code:
class SuperMailer < ActionMailer::Base
def email
from "test#domain.com"
subject "Hello"
recipients "myemail#domain.com"
tag "big-bang" end
end
However, I do not know where to add this class, and how to use it. I Do I add it in the application.rb file in the module of my app?
And how do I use this class to send the email on after submit (i.e. when someone presses Submit)?
I wrote the form with the submit button in an html file in my static_pages under app > views
Do I do the following?
<form name="contactform" method="post" > ...
The Action Mailer Rails Guide Is the best most comprehensive guide on this - it's easy to read and well worth your time.
As to your question - it's waaay too vague to answer (you have asked multiple questions here, not just one)- but in this case, all the answers are in the Rails Guide.
but for one: you put mailers in the app/mailers directory
and two: you have to set up a controller action for your form-action that calls eg: SuperMailer.email.deliver
but really: read the guide it will answer your questions
Related
I have created a web page template using html,bootstrap and css. Now, I have to see it run in my rails application. Can anyone help me by telling the way to do it step by step? What all things have to be done from the beginning for the same?
Please help!
You should really follow a tutorial about how to create a ruby on rails app to learn all the basics.
Short version: you need
a controller with an action
a route for your action
a html file with the action name
a scss file with your stylesheet
A real basic version of what it could looks like :
config/routes.rb
root :to => "static_pages#home"
app/controller/static_pages_controller.rb
class StaticPagesController < ActionController::Base
def home
end
end
app/views/static_pages/home.html.erb
Hello World
app/views/layout/application.html.erb:
Let the default (it wraps your home.html.erb file and include your application stylesheet)
app/assets/stylesheets/application.scss: It requires your other stylesheets
//= require home
app/assets/stylesheets/home.scss
Puts your style in it
I was working on a web app prior to finding meteor and to have multiple pages I had things like this (I'm using bootstrap):
signup
In order to have a button for a user to sign up. I'm trying to convert this to a template in order to work with the meteor framework. I made a template that had all the code from my signUp.html file and changed that line of code to look like this:
signup
and this gave me the following error:
INCLUSION template tag is not allowed in an HTML attribute
I changed it again to be like this:
<a {{> signUp}} class="btn btn-lg btn-default">signup</a>
and I got this error:
Reactive HTML attributes must either have a constant
name or consist of a single {{helper}} providing a dictionary of names and
values. A template tag of type INCLUSION is not allowed here.
Any help would be appreciated.
What you really need is a router. Check out iron router
You can add it using
meteor add iron:router
Then, set up the routes for your signup page. (Assuming that you have named the template as "signUp" )
Router.route('/signup', function () {
this.render('signUp');
});
And finally use the link as :
signup
I was just working on a project that was sending an extra request and it was because of data-remote="true". I've seen this line plenty of times before, but I guess I don't really know what it does. I tried Googling it but all that comes up are specific examples where data-remote isn't working for the question asker.
I just want to know what the purpose of data-remote="true"/"false" is to get a better understanding of it.
data-remote = "true" is used by the Ruby On Rails framework to submit the form/link/button as an ajax request. If you are interested here is the guide discussing how Ruby on Rails works with javascript: http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html
It is definitely not a standard thing.
Usually data-*** is a custom attribute used on application level. So check in sources of your scripts - it is used by some code.
I was told that data-remote="true" is an HTML version of JavaScript's preventDefault() method, in that it simply prevents the form from being submitted to the server.
Rails applications along with the jQuery gem generates the global listener:
$(document).on("click", "a[data-remote=true]", function(e){
e.preventDefault();
$.getScript($(this).href())
});
Feel free to correct me if I'm wrong :)
Robot Framework Version 2.8.3
Selenium2Library Version 1.4
The problem which I am facing is with regards to the controls used in the application under test.
Unlike the conventional coding technique of having the controls with ids, my application has been developed by using 'CSS - Class'.
For example a button is coded as :
where the "btn-do-login" is defined in CSS file.
Here when I enter the ids in the username and password fields, I write Click Element btn-do-login
The keyword clicks on the element but does not submits the data to the host as in the case of Submit Form keyword.
Also to mention, the application does not have any form in it. Instead there is a Div with reference to a CSS class.
Following is the entire hierarchy:
<div class="login-form">
<div class="form-element-username"> … </div>
<div class="form-element-password"> … </div>
<div id="btn-do-login" class="wbutton-login"> … </div>
</div>
Any help on how to Post data to the host is appreciated.
Also, please note that, now on entering manually the access credentials on this WebPage opened by Webdriver, and trying to submit it manually still gives me the javascript error and the page is not submitted. For logging in the application manually I need to close the browser instance (opened by Webdriver) and open a new instance manually for manual logging.
And Lastly just wanted to ask whether Selenium2Library supports HTML5 ?
This is what I have done till now.
> Login With Valid Credentials
>> Input Text ${id_login_email} ${country}
>>> Input Text ${id_login_password} ${PASSWD}
>>>> CLick Element btn-do-login
Here the variables have been defined in separate python files and have been imported as VARIABLE in the setting table.
Thanks in advance.
--Raj Sarodaya
After doing quite a few trail and errors I was able to make this work.
The problem with submit was that the javascripts were not loading as my system was behind proxy and I had not set the proxy ip in the browsers.
For many other websites proxy was not required contrary to this case hence it took some time for me to correct it.
:P
I am trying to post to a remote url from a local html file on my desktop, but the server doesn't seem o be receiving any post data?
Oopsy, The designer didn't preserve the form input name attributes... (I just assumed they did)
A form tag with action set to any web address will send to it:
<form method="post" action="http://example.com/myscript.php">
Take another look over your code to make sure you haven't forgotten anything. Showing us the HTML might help answers.