class MyClass
attr_accessor :name, :surname, :email
end
obj = MyClass.new
hash = {name: 'Ivan', surname: 'Ivanov', email: 'ivan@ivanov.com'}
hash.each do |key, value|
obj.public_send(%Q{#{key}=}, value) if obj.respond_to?(%Q{#{key}=})
end
p obj # => #<MyClass:0x007f9a4c11c478 @name="Ivan", @surname="Ivanov", @email="ivan@ivanov.com">
def callback_profile
render json: { text: 'Запрос успешно прошел.'}
end
$ ->
$("#callback_profile").on("ajax:success", (e, data, status, xhr) ->
$("#btn_submit").replaceWith data['text']
).on "ajax:error", (xhr, status, error) ->
$("#btn_submit").replaceWith 'Error!'
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
$name = $_POST['texts'];
echo $name;
}
else {
//index code
}
if(isset($_GET['context']))
{
if($_GET['context'] == 'ajax')
/*....*/
}
/<div\s+class="first"\s*>.*<\s*\/div>\s*<div\s+class="second"\s*>.*<\s*\/div>/
>> regex = /<div\s+class="first"\s*>.*<\s*\/div>\s*<div\s+class="second"\s*>.*<\s*\/div>/
>> s = %{<div class="first">First</div><div class="second">Second</div>}
>> regex =~ s
=> 0
т.е. вхождение с 0 символа
>> s = %{<div class="second">Second</div>}
=> "<div class=\"second\">Second</div>"
>> regex =~ s
=> nil
т.е. вхождения нет
>> s = %{<div class="first">First</div>}
=> "<div class=\"first\">First</div>"
>> regex =~ s
=> nil
т.е. вхождения нет